Create super-smart folders
Unleash the power of a little-known automation feature built into OS X
Unleash the power of a little-known automation feature that’s built into OS X
Could be tricky
IT WILL TAKE
As little as 10 minutes
for a simple one
OS X 10.4 or higher
For a long time OS X has had Smart Folders, whose contents dynamically update to match criteria you set, such as ‘Pages documents opened in the last month’. But those folders are dumber than a bag of rocks compared to what you can do with Folder Actions.
Automator is one of the unsung heroes of the Mac; few people know what to do with it, and even fewer use it to make Folder Actions. Let us induct you into this most special of inner inner circles, and share with you the secrets of unlimited power. Well, so far as it applies to automating some tasks in your Mac.
A Folder Action is a script – you could also think of as a mini-app – built in Automator or using AppleScript, which you attach to a folder on your Mac. Any file you add to that folder triggers the script to run, applying the actions you specified in it to that file.
What’s in a workflow?
As with Automator itself, while it might be easy to grasp in the abstract the flexibility of Folder Actions, it can be hard to work out exactly what you can do with them – why, in other words, it matters – so on the opposite page, we’ve given examples of Automator workflows you can create yourself!
On this page, though, we explain the basics of how to set up a workflow in Automator, attach it to a folder, test it, and manage your Folder Actions. Open Automator (it’s in your Applications folder), create a new workflow and, from the range of different types offered, pick Folder Action. The only thing that makes the process of creating a Folder Action workflow different to any other – in case you’re already an Automator whizz – is that you don’t need to add any file‑specifying actions such as Get Selected Finder Items or Get Specified Finder Items to tell it what to process. Once the workflow is attached to a folder, it will automatically act on any items dropped into that folder, so you don’t need to do anything else to tell the workflow what to process. (On old versions of OS X, you have to save the workflow as a plug-in, specify its type as Folder Action, then tie it to a folder.)
Instead, note the drop-down menu at the top of the workflow, which allows you to specify which folder it should be attached to; you can set this at any time during the building of your workflow.
Now, to build your workflow, browse the list of actions in the pane on the left of the Automator window, and drag the ones you want into empty pane on the right. These actions ‘click together’ in that right-hand pane, so that if, for example, you want to create a Folder Action that both resizes screenshots and converts them from PNG to JPEG, you can drag in the Scale Images action and then drag and drop the ‘Change Type of Images’ action below it. The files are first resized as specified, then the resized versions are passed to the next action to be converted to your requested format.
Folder Actions are easy scripts that act on any files added to folders they are attached to
Manage Folder Actions
Once you’re happy with the structure of the workflow, and have specified the folder it should be attached to, close and save it, then add a copy of a file – in case anything goes wrong – to that folder and check it does what you expect; you’ll see a cog appear in the menu bar while the workflow is running in the background. If not, go back to Automator, open the workflow under File > Open Recent… and check its configuration again.
To manage your Folder Actions – to see which folders have them attached, and to remove them if necessary – right-click any folder and choose Services > Folder Actions Setup. The workflows themselves are stored in ~/ Library/Workflows/Applications/Folder Actions.
Easily snap together actions which will act on any files you drop into a folder of your choice.
OS X includes some built‑in Folder Actions, such as this one to get an alert when a file is added.