Add AppleScript support to Preview
Apple’s scripting language, AppleScript, is a powerful tool for automating the things you do most often. (For AppleScript basics, see “Using Tiger: Learning AppleScript” at macworld.com/2343.) So it’s surprising that Apple’s own Preview—the Mac’s default application for opening most images—doesn’t support it.
With some know-how, an intrepid user can fix that. You won’t get perfect or complete AppleScript access, but you will gain the basic suites—Standard Suite, Text Suite, and Type Definitions. With these working, you can create time-saving scripts that manipulate windows, print images, open and close files, and so on.
So how do you add AppleScript support? Probably the quickest way is to use Terminal. Open Terminal (/Applications/Utilities) and type this command (or copy and paste it ):
defaults write /Applications/Preview.app/ Contents/Info NSAppleScriptEnabled -bool YES
That’s it—not too hard, was it?
What did you actually do? You just told the system to modify the Info.plist file for Preview by adding one Boolean (YES or NO) variable (
NSAppleScriptEnabled) and setting it to YES—in other words, enabling it. Just that will gain you a fair amount of AppleScript functionality in Preview.
To see an example, open an image with Preview and then switch to Script Editor (/Applications/AppleScript). Type this command and click on Run:
tell application "Preview" close window 1 end tell
The Preview window will vanish. Nice!
To use an advanced Preview script that takes advantage of the newly added AppleScript support, go to the Red Sweater Blog.
Spring into action
If you’re new to the Mac, you may be surprised to discover that all OS X folders have a built-in spring mechanism. No, they don’t bounce like cars on a dirt road. Instead, they spring open when you need them to—no clicking required. This greatly eases the task of filing things. There’s no need to open two windows to see the source and the destination at the same time. Instead, pick up the item you wish to file, and use spring-loaded folders to navigate to the destination. Here’s how it works.
The Basics A spring-loaded folder is nothing more than a folder that opens automatically and shows you its contents when you drag something onto it—drag and hold, that is, not drag and drop. Try it: click and hold on a file on your desktop (or elsewhere). Keep holding the mouse button down and drag the file over to any folder. Now wait (keep holding that mouse button down!). After about a second or so, the folder over which the cursor is hovering will open, revealing its contents.
Exactly what you see depends on which Finder view mode you’re using. In both the Icon and the List views, OS X will open a new window showing the folder’s contents. In Column view (my favorite), the folder’s contents will become visible in the next empty column.
Keep holding down the mouse button to dive deeper into your hard drive. After the first new window opens, find another folder and drag your file over it, wait a second, and watch it open. Releasing the mouse button will move whatever file you’ve been dragging into the frontmost window. But if you don’t want to move the file you’re dragging—or if you change your mind—you can cancel at any time by pressing the escape key. The dragged file will disappear from under your mouse and return to its original location. (You must press escape while you’re still holding down the mouse button.)
Ways to Speed Things Up If you do this often, though, you’ll soon be frustrated by that one-second delay each time you open a folder on the way to your destination. You can hurry things up by going to Finder: Preferences and clicking on the General tab. At the bottom of the window, you’ll see a Delay slider that controls the length of the delay before a spring-loaded folder pops open.
Even if you’re looking for speed, I don’t recommend moving this slider all the way to the left toward Short. Folders will accidentally pop open all the time as you drag objects around, and—trust me—this is a real pain.
So here’s my remedy. It requires an extra key press, but it removes all question as to which folder you wish to open. To gain complete control over spring-loaded folders, turn the feature off. That’s right; deselect the Spring-Loaded Folders And Windows option in the General tab of the Finder Preferences window.
Once you do, you’ll be able to pop open any folder without delay: just drag an object onto the folder, press the spacebar (while still holding the mouse button down), continue to the next folder, press the spacebar again, and so on. This makes the process both fast and accurate.
[ Senior Editor Rob Griffiths runs MacOSXHints.com. ]