Folder actions are one of the many hidden gems of macOS. You can set an action to occur whenever the contents of a folder change. It could be a simple action taken from a list provided by Apple with macOS, an AppleScript, or a workflow produced in Automator. Automator allows you to extend these actions into Terminal shell scripts and other languages.
You can use folder actions for many disparate purposes:
Resize images or convert them to another file format when added to a folder.
Provide a pop-up alert when items are added to a folder through an automated process that you wouldn’t otherwise know had completed.
Add a downloaded MP3 to the Music app.
Control-click any folder in Finder and choose Services > Configure Folder Actions in Monterey. In early versions of macOS, the option appears in the main pop-up item lists. To prevent malicious and accidental installation of Folder Actions, macOS requires a confirmation step that cannot be automated: click Run the service in the Confirm Service dialog box. This adds the current folder to the Folders with Actions list without adding actions.
The Configure Folder Actions window appears with a dialog already open that says Choose a script to attach. This list includes those that Apple has seeded, placing them inside the /Library/Scripts/Folder Actions Scripts case. Any scripts installed by apps or that you have created and placed in your home directory ~/Library/Scripts/Folder Actions Scripts folder also appears.
The folder actions configuration shows all the folders that macOS monitors. Select any folder to see which scripts are attached. You can use checkboxes to enable or disable scripts and enable or disable folder monitoring for each folder.
You can create folder actions in several ways:
Use an item provided by Apple in the dialog box that appears when you invoke Folder Actions Setup. These mainly relate to image processing.
Write your own AppleScript to perform a task.
AppleScript is relatively easy to write and can be adapted from simple recipes. Apple offers this in its developer documentation for the feature. I also recommend reading Jessica Thornsby’s article.
You can also use AppleScript as a simple piece of connective tissue. For example, I have a workflow in Flying Meat’s Retrobatch Pro image processing software that places a border around an image. A simple AppleScript turns a folder into a spring-loaded relay for Retrobatch Pro operation.
If you need more sophisticated watched folder behavior, turn to Noodlesoft’s Hazel, a supercharged third-party version of Folder Actions.
Ask for Mac 911
We’ve compiled a list of our most frequently asked questions, along with answers and column links: read our awesome FAQ to see if your question is covered. Otherwise, we are always looking for new problems to solve! Email yours to firstname.lastname@example.org, including screenshots if available and if you want your full name used. Not all questions will be answered, we don’t respond to emails, and we can’t provide direct troubleshooting advice.