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

Mention OS X and macOS Folder Actions utility to most Mac users and you get a puzzled look. Folder Actions are not well known, but the powerful automation service directs your computer 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, an AppleScript attached to the folder via the Folder Actions utility is executed. The task it performs is up to you. Most users take advantage of one of the many pre-made AppleScripts that are included with OS X and macOS.

However, users who are familiar with AppleScript can write their own folder actions. If you want to learn more about AppleScript, you can start with Apple's online documentation: Introduction to AppleScript.

Information in this article applies to Macs running OS X Mavericks (10.9) through macOS Mojave (10.14).

Shared Folder Automation Scenario

Suppose you and your partner work on a small home network that consists of various computers, printers, and other shared resources. Your offices are in different parts of the house, and you often exchange files during the day. You could use email to send these files to each other, but more often than not, you copy the files to shared folders on your computers. This method is handy for quick drag-and-drop file sharing, but unless one of you sends a message to the other, you don't know that there's a new file in the shared folder unless you 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 displays a dialog box announcing that the folder has a new item.

Create the New Item Alert Folder Action

Choose a folder that you want to be monitored for when something new is added to it. You can select a shared folder on the 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 locate the folder you want to use, perform the following steps:

  1. Right-click the folder you want to monitor and select Folder Actions Setup in the pop-up menu.

    Mac contextual menu showing Folder Actions Setup option
  2. Click Run Service in the Confirm Service window that opens.

    Confirm Service window for folder actions on a Mac
  3. In the list of available folder action scripts that opens, highlight add - new item alert.scpt and click Attach.

    LIst of pre-populated folder actions on a Mac
  4. Check Enable Folder Actions if it is not already checked. Also, place a check mark in front of the folder you want to monitor to turn on the folder action. Confirm that add - new item alert.scpt is checked as well.

    Folder Actions Setup window showing folders and scripts
  5. Close the Folder Actions Setup window.

Now whenever an item is added to the specified folder, a dialog box pops up to notify you that a new item has arrived.

Folder action alert screen

The Folder Action Alert dialog box gives you the option of viewing the new item(s) immediately. The dialog box eventually dismisses itself, so if you're off having lunch, you could miss a notification.