Folder Actions are one of many hidden gems in macOS. You can set an action to occur whenever the contents of a folder are changed. This can be a simple action drawn from a list that Apple provides with macOS, an AppleScript, or a workflow produced in Automator. Automator lets you extend these actions into Terminal shell scripts and other languages.
You can use Folder Actions for a lot of disparate purposes:
- Resize images or convert them another file format when they're added to a folder.
- Provide a popup alert when items are added to a folder through an automated process that you otherwise wouldn't know had completed.
- Add a downloaded MP3 to the Music app.
The Folder Actions Setup window manages all watched folders and attached scripts.
Control-click any folder in the Finder and choose Services Folder Actions Setup in Monterey. In early versions of macOS, the option appears in the main lists of contextual items. To avoid the malicious and accidental installation of Folder Actions, macOS requires a confirmation step that can't be automated: click Run Service in the Confirm Service dialog. This adds the current folder to the Folders with Actions list without adding actions.
The Folder Actions Setup window appears with a dialog already open that reads Choose a Script to Attach. This list includes ones that Apple seeded, locating them inside the
/Library/Scripts/Folder Actions Scripts folder. Any scripts installed by apps or that you've created and placed inside your Home directory's
~/Library/Scripts/Folder Actions Scripts folder appear as well.
Folder Actions Setup shows all folders macOS is watching. Select any folder to see which scripts are attached. You can use checkboxes to toggle scripts on or off and folder watching for each folder on or off.
You can create Folder Actions in a numbers of ways:
- Use an item Apple provides in the dialog that appears when you invoke Folder Actions Setup. These mostly 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 some in its developer documentation of the feature. I also recommend reading Jessica Thornsby's article.
You can use AppleScript as a simple bit of connective tissue, too. For instance, I have a workflow in Flying Meat's Retrobatch Pro image-processing software that puts a border around an image. A simple AppleScript turns a folder into a spring-loaded passthrough for the Retrobatch Pro operation.
This stub of a script lets me drop images into a folder and have macOS automatically run a Retrobatch Pro workflow.
If you need more sophisticated watched-folder behavior, turn to Hazel from Noodlesoft, a supercharged third-party version of Folder Actions.
Ask Mac 911
We've compiled a list of the questions we get asked most frequently, along with answers and links to columns: read our super FAQ to see if your question is covered. If not, we're always looking for new problems to solve! Email yours to [email protected], including screen captures as appropriate and whether you want your full name used. Not every question will be answered, we don't reply to email, and we cannot provide direct troubleshooting advice.