Ledge

How to make a Mac folder act on every file you drop in it

A folder action is a set of steps macOS runs on anything added to a chosen folder. You build one in Automator: create a Folder Action, pick the folder, add steps such as Change Type of Images or Rename Finder Items, and save. From then on, every file you drop into that folder gets the same treatment without you doing anything else.

Build a folder action in Automator

Automator comes with macOS and lives in the Applications folder.

  1. Open Automator. In the dialog that appears, choose Folder Action and click Choose. If no dialog appears, choose File > New.
  2. At the top of the workflow area you will see “Folder Action receives files and folders added to” followed by a pop-up menu. Open it, choose Other, and select the folder you want to watch. A new, empty folder is the safest choice for a first try.
  3. In the Library on the left, type in the search field to find an action, then drag it into the workflow area on the right. Add more actions underneath; each one passes its results to the next.
  4. Set the options inside each action, such as the image format or the naming pattern.
  5. Choose File > Save and give the folder action a name that says what it does, such as Convert to JPEG.

Now drop a file into the folder. After a moment, often a few seconds, the actions run. A turning gear may appear in the menu bar while the work is in progress.

Useful actions to start with

A handful of actions cover most everyday jobs:

  • Change Type of Images converts each image to a format you pick, such as JPEG, PNG or TIFF. Handy for a folder of screenshots or phone photos that need to be in a common format.
  • Scale Images resizes images to a width in pixels or by a percentage.
  • Rename Finder Items can add a date or some text, replace text, change case, or number files in sequence.
  • Move Finder Items and Copy Finder Items send the results to another folder when the work is done.
  • Filter Finder Items lets only files that match a rule, such as Kind is Image, carry on to the next step. Put it first when the folder might receive a mix of file types, so a PDF dropped into an image folder is skipped rather than causing an error.

When you add an action that changes files in place, Automator asks whether to add a Copy Finder Items action so copies are changed and your originals kept. Choose Add to keep the originals, then set where the copies go. Choose Don’t Add if you want the files changed directly.

Here is a worked example: a folder called To JPEG that turns any image you drop into it into a JPEG and moves the result to Pictures.

  1. Filter Finder Items: Kind is Image.
  2. Change Type of Images: To Type JPEG. When Automator asks about copies, choose Don’t Add if you no longer need the original format.
  3. Move Finder Items: To Pictures.

Save it, drop a PNG screenshot into To JPEG, and a JPEG shows up in Pictures a few seconds later.

Avoid the loop

The most common folder action mistake is a loop. A folder action runs on anything added to its folder, and that includes files the action itself creates there. If an action writes its output into the watched folder, that output counts as a new arrival and the action runs again on it.

The fix is to finish every folder action with Move Finder Items or Copy Finder Items pointed somewhere else. Folder actions watch only the folder itself, not the folders inside it, so a subfolder called Done also works as a destination.

Two more cautions:

  • It runs on every arrival, not just drags. Saving from an app, a finished download and a copy from a drive all count. Think twice before attaching an action to a busy folder such as Downloads, where a file that is still being written can trigger it early.
  • Test on copies first. Until you trust a new folder action, feed it duplicates. Select a file in Finder and press Command-D to make one, then drop the duplicate in.

Turn folder actions off or change them

Control-click the watched folder in Finder and choose Folder Actions Setup. Depending on your version of macOS, it sits under Services or Quick Actions near the bottom of the menu.

The window that opens has three parts:

  • an Enable Folder Actions checkbox at the top, which switches every folder action on or off at once;
  • a list of watched folders on the left, each with its own checkbox;
  • the actions attached to the selected folder on the right, which you can untick or remove with the minus button.

To change the steps themselves, open the saved workflow in Automator. The folder actions you make are kept in your Library. In Finder, choose Go > Go to Folder, paste ~/Library/Workflows/Applications/Folder Actions and press Return. Double-click a workflow to open it, make your changes and save.

When a fixed rule is the wrong tool

A folder action is a standing rule: the same thing happens to every file, every time. That suits repeat jobs, like converting screenshots or renaming scans. It fits poorly when the destination changes with each file: this one into a chat, that one’s path into a terminal, the next into a project folder.

That is the gap Ledge fills. Drag a file up to the notch and let go; it waits on a shelf that drops from the notch. When you drag it off, each destination gets the form it can use. A terminal receives the path as text, a chat app gets the file uploaded, and a Finder window gets the file itself. You decide with each drop, and there is no rule to maintain. Routing the same file to different apps differently shows how that plays out over a day.

The two also combine well. Drag a file from the shelf onto a watched folder in a Finder window and the file moves into it, so the folder action runs on it as usual. Ledge has no rules of its own and never edits your files; it holds them and hands them over.

Questions

Will a folder action run on files that were already in the folder?

No. It reacts only to items added after it is attached. To process files that were already there, move them out and drop them back in.

Does a folder action run when I am logged out?

No. Folder actions run inside your user session, so they work while you are logged in. Nothing watches the folder while you are logged out.

Why did my folder action do nothing?

Open Folder Actions Setup and check three things: that Enable Folder Actions is ticked, that the folder is ticked in the left list, and that the workflow is ticked on the right. Then check the file actually matched any Filter Finder Items rule at the top of the workflow.

Can I attach more than one folder action to the same folder?

Yes. Each appears as its own line on the right side of Folder Actions Setup. Bear in mind they all react to the same arrivals, so make sure they do not fight over the same files.