Turn on Folder Actions globally
To use Folder Actions, you must first turn this feature on globally. To do this, right-click or Control-click on any folder and choose Services -> Folder Actions Setup. (If you only have a few Services, you may not have a Services menu and will instead see the Folder Actions Setup menu item at the bottom of the contextual menu.) When you choose Folder Actions Setup, a small window opens showing a list of AppleScripts. Select Enable Folder Actions in the window and then quit (Command-Q).
Get alerted to incoming files
Now, let’s apply a simple, useful folder action to one of your folders. If you share files with others over a network, your colleagues may deposit files in your Mac’s built-in Drop Box folder. But how do you know when a new document has arrived? Add a Folder Action that displays a dialog box whenever a new file is added to this folder.
To do this, first go to your Public folder. You’ll find it inside your home folder—the one with the house icon. (Or, in the Finder select Go -> Go To Folder and type ~/Public/
). Right-click or Control-click on the Drop Box folder inside, choose Folder Actions Setup, click on “add – new item alert.scpt,” and then click on Attach.
Another way to use this same script is with your Dropbox folder. If you share files using Dropbox’s shared folders, you may want to know when you receive new files. Dropbox offers “desktop notifications”—floating alerts—but they fade away after a few seconds. Attach the same script we used above to a shared folder and you’ll see an alert whenever Dropbox downloads new files to that folder. Note that this only works when an item is added to the folder itself, not when someone adds an item to one of its sub-folders. If you have a lot of sub-folders in your shared folder, you can apply the same script to each of them to get alerts for all of the folders.
Explore OS X’s other built-in actions
OS X includes a handful of folder action scripts in the /Library/Scripts/Folder Action Scripts folder. Let’s look at a couple of them and see how they can save you time.
In this folder, you’ll see a number of scripts that can act on graphics. For example, there are three scripts that can automatically convert image files to JPEG, PNG or TIFF format. Let’s say you have a blog, and you want all your graphics to be in JPEG format. Create a folder somewhere and attach the “image – Duplicate as JPEG.scpt” script to it. Every time you add an image file to that folder, it will be immediately converted.
There’s a nifty script if you often open a lot of folders within a specific folder. As you know, closing all those windows can be annoying. If you attach the “close – close sub-folders.scpt” script to a folder, any sub-folders that are open will be closed when you close the top-level folder. This is useful if you have projects that require you to access files in a lot of sub-folders.
Turn off Folder Actions
I’ll follow up this article with another about more Folder Action scripts for you to try. If you have any favorites to share, please talk about them in the comments.
Senior contributor Kirk McElhearn writes about more than just Macs on his blog Kirkville. Twitter: @mcelhearn Kirk is the author of Take Control of Scrivener 2.