Duplicate files & photos

How to Automatically Sort Files by Type on a Mac (Folder Actions & Automator)

If your Downloads folder has become a digital landfill of PDFs, disk images, ZIP archives, and random screenshots, you are not alone — and there is a better way. The ability to automatically sort files by type on a Mac has been baked into macOS for years through Folder Actions and Automator, yet most users never discover it. This guide walks through every practical approach available on macOS Sequoia and the upcoming Tahoe release, covering both Apple Silicon and Intel Macs, so you can pick the method that fits your workflow.

Why Automatic File Sorting Matters for Disk Health

Sorting files is not just about tidiness. When files pile up unsorted, duplicates accumulate silently — the same installer downloaded three times, screenshots backed up twice, PDF receipts scattered across four folders. An organized folder structure makes it far easier to spot and remove the waste before it compounds. If you want to understand what is eating your storage before you start sorting, this breakdown of what takes up space on a Mac is a useful starting point.

Method 1: Automator Folder Action (No Code Required)

Automator's Folder Action workflow attaches a script to any folder and fires whenever new files land inside it. Here is how to set one up for your Downloads folder.

  1. Open Automator from /Applications/Automator.app.
  2. Choose New Document, then select Folder Action as the document type.
  3. At the top of the workflow canvas, set the Folder Action receives files and folders added to dropdown to ~/Downloads.
  4. In the action library, search for Run Shell Script and drag it onto the canvas.
  5. Set Pass input to as arguments.
  6. Paste the shell script from the next section into the text area.
  7. Save the workflow. Automator stores it in ~/Library/Workflows/Applications/Folder Actions/.
  8. Right-click ~/Downloads in Finder, choose Folder Actions Setup, and confirm the workflow is listed and enabled.

From this point on, every file dropped into Downloads will be inspected and moved automatically — no manual intervention needed.

The Shell Script: Sorting Logic Explained

The script below reads the file extension of each incoming item and moves it into a named subfolder, creating the subfolder if it does not exist yet.

#!/bin/bash
for f in "$@"; do
  ext="${f##*.}"
  ext=$(echo "$ext" | tr '[:upper:]' '[:lower:]')
  base=~/Downloads

  case "$ext" in
    pdf)              dest="$base/Documents/PDFs" ;;
    doc|docx|pages)   dest="$base/Documents/Word" ;;
    xls|xlsx|numbers|csv) dest="$base/Documents/Spreadsheets" ;;
    jpg|jpeg|png|gif|webp|heic) dest="$base/Images" ;;
    mp4|mov|m4v|avi)  dest="$base/Videos" ;;
    mp3|m4a|aac|flac) dest="$base/Audio" ;;
    zip|tar|gz|bz2|7z|rar) dest="$base/Archives" ;;
    dmg|pkg)          dest="$base/Installers" ;;
    *)                dest="$base/Misc" ;;
  esac

  mkdir -p "$dest"
  mv -n "$f" "$dest/"
done

The -n flag on mv means the move is a no-op if a file with the same name already exists at the destination, which prevents accidental overwrites. You can extend the case block freely — for example, adding sketch|fig|xd for a Design subfolder.

Method 2: macOS Monterey+ Shortcuts App

If you prefer a GUI-only path, the Shortcuts app (available since macOS Monterey, fully mature on Sequoia) can accomplish the same goal.

  1. Open Shortcuts from /Applications/Shortcuts.app.
  2. Create a new shortcut and add the action Get Type of File.
  3. Follow it with an If block that checks the file type and then uses Move File to route each type to its destination folder.
  4. At the top of the shortcut editor, enable Run as Folder Action and point it at ~/Downloads.

Shortcuts is easier to read and edit later, though complex branching logic tends to get unwieldy after more than six or seven file type branches. For heavy customisation, the shell-script approach scales better.

Method 3: launchd Agent for Continuous Background Sorting

Folder Actions fire only when Finder is the active process adding files. If you use a download manager, torrent client, or curl in Terminal, Folder Actions may miss those files. A launchd agent watching the folder with WatchPaths is more reliable.

  1. Save the sorting script as ~/Library/Scripts/sort-downloads.sh and make it executable: chmod +x ~/Library/Scripts/sort-downloads.sh
  2. Create a property list at ~/Library/LaunchAgents/com.user.sortdownloads.plist with the content below.
  3. Load it with: launchctl load ~/Library/LaunchAgents/com.user.sortdownloads.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.user.sortdownloads</string>
  <key>ProgramArguments</key>
  <array>
    <string>/bin/bash</string>
    <string>/Users/YOUR_USERNAME/Library/Scripts/sort-downloads.sh</string>
  </array>
  <key>WatchPaths</key>
  <array>
    <string>/Users/YOUR_USERNAME/Downloads</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>

Replace YOUR_USERNAME with the output of whoami in Terminal. macOS Sequoia Privacy controls may ask you to grant the script Full Disk Access via System Settings > Privacy & Security > Full Disk Access — do this once and the agent runs silently in the background.

Where Your Sorted Files End Up: A Folder Map

File Types Extension Examples Suggested Destination
Images jpg, png, heic, webp, gif ~/Downloads/Images/
Documents pdf, docx, pages, txt, md ~/Downloads/Documents/
Spreadsheets xlsx, numbers, csv ~/Downloads/Documents/Spreadsheets/
Videos mp4, mov, m4v, mkv ~/Downloads/Videos/
Audio mp3, m4a, flac, aac ~/Downloads/Audio/
Archives zip, tar, gz, 7z, rar ~/Downloads/Archives/
Installers dmg, pkg ~/Downloads/Installers/
Everything else ~/Downloads/Misc/

Handling Duplicates After Sorting

Once your files are grouped by type, duplicates become much more visible — you may discover three copies of the same macOS installer DMG sitting in ~/Downloads/Installers/, or a dozen near-identical screenshots in ~/Downloads/Images/. At this point a dedicated duplicate finder is the fastest way to reclaim that space. A tool like Crumb can audit all of these folders at once and show what is safe to delete before anything is removed, which is reassuring when the duplicates run into the gigabytes.

Troubleshooting Common Problems

The Folder Action fires but files do not move

Check that the script file has execute permission (chmod +x) and that the path inside Automator's Run Shell Script action exactly matches the saved script location. On macOS Sequoia, also verify the script is not blocked by Gatekeeper: right-click it in Finder and choose Open at least once.

The launchd agent stops after a restart

Make sure the plist is in ~/Library/LaunchAgents/ (per-user agents), not /Library/LaunchDaemons/ (system daemons). Reload it with launchctl load ~/Library/LaunchAgents/com.user.sortdownloads.plist or use launchctl enable on macOS Ventura and later.

Files downloaded via Safari are not being sorted

Safari writes a partial .download file to ~/Downloads during the transfer and renames it only when complete. Both Folder Actions and WatchPaths agents will fire on the rename event, so sorting should still work. If it does not, add a one-second sleep to the top of your script (sleep 1) to ensure the rename has fully committed before the move runs.

Reclaim your disk in one click

Crumb audits your whole Mac, tells you what's safe to delete, and frees the space in seconds — private, local, and Apple-notarized.

Download Crumb for macOS

Frequently asked questions

Is it safe to use Folder Actions to automatically move files on a Mac?
Yes. Folder Actions run as your own user account with no elevated privileges, and the shell script in this guide uses the -n flag on mv so it will never silently overwrite a file that already exists at the destination. You can disable a Folder Action at any time via Folder Actions Setup in the right-click menu.
Where does macOS store Automator Folder Action workflows?
Automator saves Folder Action workflows to ~/Library/Workflows/Applications/Folder Actions/. Each workflow is a .workflow bundle you can open, edit, or delete from that folder at any time.
Will automatic file sorting work with files downloaded by apps other than Safari?
Folder Actions are triggered by Finder events, so they may miss files written by download managers or command-line tools. The launchd WatchPaths method described in this guide monitors the folder at the filesystem level and catches all new files regardless of which app created them.
How much space can I reclaim by sorting and deduplicating my Downloads folder?
It varies widely, but Downloads folders that have been ignored for a year or more commonly hold multiple gigabytes of duplicate installers, redundant ZIP files, and old disk images. Sorting by type first makes it far easier to spot the duplicates before you delete anything.
Will files sorted into subfolders still be indexed by Spotlight?
Yes. Spotlight indexes all files under your home folder by default, including any subfolders you create inside Downloads. Searching by filename, content, or kind will still surface sorted files immediately.