After reinstalling my system recently, I had a look at the mess my windows had turned into, and started looking into AppleScript as a means to set my windows to my preferred view settings. As it turned out, there was no easy way to set the "All Windows" option -- the only scriptable commands in Finder applied to "This Window Only" settings. Then I learned about GUI Scripting, and after a couple days of trial and error I got the thing to work reliably -- here's the code.
What the script does:
You can either drop items into it or open it, in which case you will be prompted to open a folder. At the start, Finder is activated, all Finder windows are closed, and the "Show View Options" window is opened. The script also stores the username of the current user, which it needs for checking read rights for folders.
The script processes both disks and folders recursively. Each disk or folder is set to icon view, opened, moved and resized, and the sidebar width is set. Then the "This Window Only" icon view options are set to my defaults. Then "All Windows" is set for icon view options. Next, the "This Window Only" list view options are set to my defaults, and finally, "All Windows" is set for list view options. Last of all, the zoom button is clicked, which resizes the window. After all disks and folders have been processed, a dialog box is shown stating the number of folders/disks processed.
Note that you should not do anything else on the computer while the script is running. The script depends on the Finder windows remaining in a certain order, and Finder must stay active. If you do want to stop the script, close any window, and the script will harmlessly crash, displaying an error message. Note that the script takes a long time to run: in my tests, processing 300 folders took about an hour.
I'm one of those "keep my hand on the keyboard at all times" sort of guys. So I was annoyed recently when I discovered that there was no keyboard shortcut to set an item's color label in the Finder. While I don't always use the Finder's color labels, I often find them invaluable when working on projects with complex file and folder structures, indicating which files are "done" and which files are "pending." Using Butler's outstanding ability to execute any AppleScript code via a key combination, I set up the following script:
tell application "Finder"
set thisItem to selection as alias
if label index of thisItem = 0 then
set the label index of thisItem to 2 -- 2 = red
set label index of thisItem to 0 -- 0 = no label
I then set it to run with the arbitrary key-combination of Option-Command-Control-L. This code will toggle on and off the Red label only. However, using Butler and modifying the AppleScript, one could set a combo to toggle all the different labels on and off -- perhaps using one to six on your keyboard, with appropriate modifier keys.
When renaming files in Finder, click on the file, press Enter to bring up the rename input box, then while holding down Option, press the right arrow key. This will bring you to the end of the filename, but before the dot extension. Similarly, Option and left arrow brings you to the beginning. Just a little hint that may save some time while renaming.
In response to a recent Mac Gem, there is an even easier way to export the path to the current folder from the Finder: You can click on the icon next to the finder window name and then drag and drop it to your favourite text editor, or even Terminal. This also works with files in the Finder window.
Let's say you're working on a Finder window which covers another window (not necessarily another Finder window) on which there is an information you need. What do you usually do? You use Exposť, Command-Tab, etc.
But there's another solution: if you're able to read very fast, you can triple-click (as quickly as possible) the title bar of the Finder window. It will minimize and then immediately unminimize. I don't know whether this is a bug or not, but it only works with Finder.
[robg adds: Somewhat obviously, this also only works if you've enabled Minimize when double clicking a window title bar in the Appearance System Preferences panel.]
I don't like the distraction that comes with having a lot of stuff on the desktop There are lots of apps out there to hide the desktop, but some of them consume about 40MB of memory just to hide the desktop. So here's my easy, free, and RAM-conserving solution:
In the Finder, create a new folder somewhere on your hard drive. Size it to fill the screen, set the view to Icons, set the View Options to use a background color of your choice, and hide the toolbar. Close the folder. Now, whenever you need the background hidden, just open your maximized folder.
[robg adds: I use either Backdrop or Desktop Cutain to hide the desktop -- they take anywhere from 10MB to 20MB of real RAM. I used to use the folder method, but found that I wanted the added features of the application solution (it's simpler to toggle between colors and images; set the level at which the hiding occurs; etc.). To me, that's worth the 15MB or so of real RAM it requires.]
The following Automator workflow will simplify compacting a sparse disk image. You need to occasionally compact sparse disk images, because while they will grow automatically as you add files, they won't shrink when you delete files. Open Automator in Applications Folder, and create this workflow:
Finder Library » Get Specified Finder Items Action
Finder Library » Filter Finder Items, and select Name Extension is equal to sparseimage.
Automator Library » Run Shell Script and select Pass input as arguments and replace the sample script with hdiutil compact $@.
Save as Plugin for Finder (name it Compact Sparse Disk Image). In the Finder, select a sparse disk image and ctrl-click, go to the Automator entry, and select Compact Sparse Disk Image. That's it!
Whenever I open TextEdit (rarely), I am dismayed to find out that when I save the file, it only gives me four choices: RTF, HTML, Word, and Word XML. But what happens when I don't care about the formatting, and all I want is plain old txt? For a while I found myself opening a blank text file on my desktop downloaded from a website and then doing File » Save As, or even opening up Terminal and typing in touch Desktop/file.txt.
Well, today I got off my lazy butt and wrote a script (two lines of code). I then put it into Automator and saved it as a plug-in in the Finder's contextual menu. Here's the script:
do shell script "touch ~/Desktop/file.txt"
do shell script "open ~/Desktop/file.txt"
What the script does is first create a file named file.txt and puts it on the desktop, then opens it in TextEdit. I suppose someone could save the script as an application and have it open on a keyboard shortcut through Butler or Quicksilver as well. Just copy the code into Script Editor or Automator in a Do Shell Script action.
[robg adds: There are third-party tools that make this process pretty simple, too. DocumentPalette and NuFile are two that come to mind.]
One detail that I'm actually missing from Windows is a Finder toolbar button to jump one folder up in the hierarchy, ie to the parent folder. So I came up with the following ugly but still functionally work-around. First create an AppleScript app with just this line of code:
tell application "Finder" to set target of window 1 to the container ¨
of target of window 1
Then save it as an application, and quit Script Editor. Now show the contents of the application package you just created by control-clicking on the folder and then choosing Show Package Contents from the pop-up menu. Open the Contents folder and edit the info.plist file in your editor of choice. Adding the following will make the program faceless, so that it does not appear in the Dock when launched:
Finally create a nice icon (I made one in Photoshop that looks similar to the navigation buttons, as seen above right), paste it onto the app (in its Get Info window) and drag the app to the Finder toolbar. Done! It looks a little strange when the window is inactive (the icon gets dimmed, differently from the other buttons), but it does work.