Setup OS X Folder Actions to Know When a File is Added

OS X Folder Actions
Screen shot courtesy of Coyote Moon, Inc.

Mention OS X's Folder Actions utility to most Mac users and you'll likely get a bit of a puzzled look. Folder Actions may not be well known, but it's a powerful automation service that allows you to perform a task whenever a folder that's being monitored undergoes one of the following changes: the folder is opened or closed, moved or resized, or has an item added to or removed from it.

When an event occurs to a monitored folder, the AppleScript attached to the folder via the Folder Actions utility is executed. The task that is performed is up to you; it can be just about anything that can be expressed in an AppleScript. This is a fantastic workflow automation tool that you can use in a myriad different ways.

The key to successful workflow automation with Folder Actions is a repetitive task or event. In order to implement Folder Actions, you must create an AppleScript to perform the task for you. AppleScript is OS X's built-in scripting language. It's somewhat easy to learn, but teaching you how to create your own AppleScripts is beyond the scope of this tip.

Instead, we're going to take advantage of one of the many pre-made AppleScripts that's included with OS X. If you would like to learn more about AppleScript, you can start with Apple’s online documentation: Introduction to AppleScript.

The Event to Automate

My wife and I work on a small home network that consists of various computers, printers, and other shared resources. Our offices are in different parts of the house, and we often exchange files during the day. We could use email to send these files to each other, but more often than not, we just copy the files to shared folders on our computers. This method is handy for quick drag-and-drop file sharing, but unless one of us sends a message to the other, we don't know that there's a new file in our shared folder unless we happen to look.

Enter Folder Actions. One of the pre-made AppleScripts for Folder Actions is called 'new item alerts.' As you can guess from its name, this AppleScript watches a folder you specify. When something new is added to the folder, the AppleScript will display a dialog box announcing that the folder has a new item, a simple and elegant solution. Of course, this means I no longer have an excuse for not working on a new file, but everything has its downside.

Create the Folder Action

To get started with our example, you'll need to select a folder that you wish to be monitored for when something new is added to it. In our case, we selected a shared folder on our local network, but it could also be a folder you use for syncing information via the cloud, such as Dropbox, iCloud, Google Drive, or Microsoft’s OneDrive.

Once you have navigated to the folder you wish to use, perform the following steps:

  1. Right-click the folder you want to monitor.

  2. Select ‘Configure Folder Action' from the pop-up menu. Depending on the version of OS X your using, it may also be called 'Folder Action Setup' located under the Services menu item. To make it even a bit tougher to find, it may also be listed under the 'More' item if you have quite a few contextual menu items installed.

  3. Depending on the version of OS X you are using, you may see the list of available folder action scripts, or the Folder Action Setup window. If you see the list of available scripts jump to step 8, otherwise continue to step 4.

  4. The Folder Actions Setup window will appear.

  5. Click the ‘+’ sign at the bottom of the left-hand list to add a folder to the list of Folders with Actions.

  6. A standard Open dialog box will display.

  7. Select the folder you want to monitor and click the ‘Open’ button.

  8. A list of available AppleScripts will display.

  9. Select ‘add – new item alert.scpt’ from the list of scripts.

  10. Click the ‘Attach’ button.

  11. Make sure the 'Enable Folder Actions' box is ticked.

  12. Close the Folder Actions Setup window.

Now whenever an item is added to the specified folder, a dialog box will display the following text: ‘Folder Action Alert: One new item has been placed in folder ‘{folder name}.' The Folder Action Alert dialog box will also give you the option of viewing the new item(s).

The Folder Actions Alert dialog box will eventually dismiss itself, so if you're off having tea, you could miss a notification.