Introduction to Mac Automation

Automation is the quiet superpower of macOS. While most users click through the same tedious sequences dozens of times a day — renaming screenshots, resizing images, filing invoices, converting file formats, posting status updates — power users build small, resilient workflows that do these tasks for them, often in a single keystroke or triggered automatically by the operating system itself. Over the course of a year, those saved seconds compound into days of reclaimed time, fewer context switches, and dramatically less cognitive fatigue.

macOS offers something no other consumer operating system does: a layered automation stack that spans from drag-and-drop visual builders to full Unix scripting. At the top sits the modern Shortcuts app, which Apple ported from iOS and now treats as the primary automation surface for both Mac and iPhone. Below it lives Automator, the venerable 2005-era workflow editor that still runs beautifully and remains the fastest way to build folder-watching services and Quick Actions. Underneath those sits AppleScript, Apple’s English-like scripting language that can drive almost any scriptable app on the system, and below that is the full POSIX shell — zsh, bash, Python, Node, Ruby, Perl — running on a certified Unix core.

You don’t have to pick one. The most powerful macOS automations are hybrids: a Shortcut triggers an AppleScript, which runs a shell command, which pipes output into a text file that a folder action notices and processes. In this guide you’ll learn each layer well enough to build real workflows, and more importantly, you’ll learn how to combine them.

💡 Who this guide is for: Mac users comfortable with basic macOS navigation who want to move beyond manual repetition. No prior scripting experience required — we start with visual tools and build upward.

What You’ll Build

By the end of this guide you’ll be able to construct workflows such as: automatically converting any PNG dropped into a folder into optimized JPEGs, resizing screenshots on save, batch-renaming hundreds of files by pattern, launching your “work mode” (apps, windows, Do Not Disturb, playlist) with one keystroke, running a backup script every night at 2 a.m., and extracting text from PDFs into Markdown notes. These are not toy examples — they’re the exact kinds of workflows professional developers, designers, writers, and researchers rely on every day.

Shortcuts App Deep Dive

The Shortcuts app, built into macOS since Monterey, is Apple’s long-term automation strategy. It replaces the aging Automator user interface with a modern, iCloud-synced, action-based builder that works identically on iPhone, iPad, Mac, and Apple Watch. Any Shortcut you build on one device can run on the others — a genuinely remarkable piece of cross-platform engineering.

Opening Shortcuts and the Interface

Launch Shortcuts from Applications or press ⌘ + Space and type “Shortcuts”. The sidebar lists collections: All Shortcuts, Quick Actions, Menu Bar, Services, and any folders you create. Click the + button to create a new Shortcut, then drag actions from the right-hand action library into the workflow canvas.

Your First Shortcut: Resize Image on Clipboard

Let’s build a practical Shortcut that takes an image on your clipboard, resizes it to 1200px wide, and copies it back. Create a new Shortcut and add these actions in order:

  1. Get Clipboard — reads the current clipboard contents.
  2. Resize Image — set Width to 1200 and leave height on Auto.
  3. Copy to Clipboard — writes the resized image back.
  4. Show Notification — “Image resized to 1200px”.

In the Shortcut details pane on the right, assign a keyboard shortcut like ⌃ + ⌥ + ⌘ + R and tick Pin in Menu Bar. You now have a system-wide image resizer that works from any application.

Running Shortcuts from the Command Line

Every Shortcut can be invoked from the terminal using the shortcuts CLI, which makes them scriptable from anything that can call a shell:

# List every Shortcut by name
shortcuts list

# Run a Shortcut by name
shortcuts run "Resize Image"

# Pass input via stdin
cat photo.png | shortcuts run "Resize Image" --output-path resized.png

# View a Shortcut’s structure
shortcuts view "Resize Image"

Triggers and Automation

On macOS Ventura and later, the Shortcuts app includes a dedicated Automation tab that fires workflows on events: time of day, when you connect to a specific Wi-Fi network, when a particular app opens or closes, or when a file is added to iCloud Drive. Combined with the native Focus system, you can automatically launch your “Deep Work” Shortcut whenever Work Focus turns on.

✅ Pro tip: Give every Shortcut a short, verb-first name (“Resize Image”, “Convert to PDF”). This makes them easy to invoke by voice through Siri and easy to find in Spotlight.

Automator Legacy Workflows

Automator is Apple’s original automation application, first released with Mac OS X Tiger in 2005. Despite being officially superseded by Shortcuts, it is still installed on every modern Mac, is actively maintained, and remains the fastest path to certain kinds of automation — particularly folder-triggered workflows and system-wide right-click Quick Actions.

Workflow Types

When you create a new Automator document you choose a type, and each type decides where and how the workflow will appear in macOS:

TypeWhere It AppearsBest For
WorkflowRuns inside AutomatorTesting and one-off batch jobs
ApplicationDock, Desktop, LaunchpadDrag-and-drop file converters
Quick ActionFinder right-click & Services menuContext-sensitive file operations
Folder ActionAttached to a specific folderAuto-processing new files
Calendar AlarmFired by Calendar eventsTime-based scripts
Image Capture PluginImage Capture appScanner / camera workflows
Print PluginPrint dialog PDF menuSave-as-PDF post-processing
Dictation CommandVoice-triggeredHands-free macros

Example: Batch Convert HEIC to JPEG

Create a new Quick Action in Automator. Set Workflow receives current to image files in Finder. Drag in these actions:

  1. Copy Finder Items — destination: a “Converted” folder on your Desktop.
  2. Change Type of Images — To Type: JPEG.

Save it as “Convert to JPEG”. From now on, selecting any images in Finder and right-clicking will show a Quick Actions → Convert to JPEG option. That is the kind of workflow Shortcuts still cannot build as elegantly in 2026.

⚠️ Heads up: Automator and Shortcuts are not fully interchangeable. Some actions — particularly the Run Shell Script block with input piping and certain Finder-centric file operations — are still handled better by Automator.

Shell Scripts & Terminal

Beneath every GUI automation on macOS sits a certified Unix. The default shell since Catalina is zsh, and it ships with the same powerful toolkit any Linux user would recognize: awk, sed, grep, find, xargs, curl, rsync, and the full GNU-compatible stack through Homebrew. If you can describe a repetitive task in words, you can almost always script it in a few lines of shell.

Writing Your First Script

Open Terminal and create a script that archives your Downloads folder nightly:

#!/usr/bin/env zsh
# archive-downloads.sh
# Compresses yesterday’s downloads into a dated tarball.

set -euo pipefail

SRC="$HOME/Downloads"
DEST="$HOME/Archives"
DATE=$(date +%Y-%m-%d)

mkdir -p "$DEST"
tar -czf "$DEST/downloads-$DATE.tar.gz" -C "$SRC" .
find "$SRC" -maxdepth 1 -mindepth 1 -mtime +1 -delete

echo "Archived to downloads-$DATE.tar.gz"

Save it as ~/bin/archive-downloads.sh, make it executable with chmod +x ~/bin/archive-downloads.sh, and run it with ./archive-downloads.sh. That’s a complete, production-ready automation in 12 lines.

Useful One-Liners

# Flatten a nested folder tree into one folder
find ~/Photos -type f -exec mv {} ~/Photos-flat/ \;

# Rename every .jpeg to .jpg
for f in *.jpeg; do mv "$f" "${f%.jpeg}.jpg"; done

# Watch a log file in real time
tail -f /var/log/system.log

# Convert every PNG in a folder to WebP (requires cwebp)
for f in *.png; do cwebp "$f" -q 85 -o "${f%.png}.webp"; done

# Empty every Trash on every mounted volume
sudo rm -rfv /Volumes/*/.Trashes ~/.Trash/*

Running Shell Scripts from Shortcuts and Automator

Both the Shortcuts app and Automator include a Run Shell Script action. In Shortcuts you select the shell (zsh is standard) and whether the previous step’s output is piped as stdin or passed as arguments. This is the glue that lets a visual workflow call into the full power of Unix.

AppleScript Essentials

AppleScript is Apple’s English-like scripting language, dating to 1993 and still unmatched for one specific job: controlling macOS applications. Where shell scripts talk to files and processes, AppleScript talks to apps — Mail, Safari, Finder, Keynote, Numbers, Pages, Music, Messages, OmniFocus, BBEdit, and hundreds of others expose scripting dictionaries you can inspect and automate.

Hello, Script Editor

Open Script Editor (Applications → Utilities). Paste this and press ⌘ + R:

tell application "Finder"
    set desktopItems to count of items of desktop
    display notification "You have " & desktopItems & " items on your desktop" with title "Desktop Report"
end tell

A More Useful Example: Compose Email from Selected Finder Files

tell application "Finder" to set theFiles to selection as alias list

tell application "Mail"
    set newMessage to make new outgoing message with properties {subject:"Files for review", content:"See attached." & return & return}
    tell newMessage
        repeat with aFile in theFiles
            make new attachment with properties {file name:aFile} at after last paragraph
        end repeat
        set visible to true
    end tell
end tell

Select any files in Finder, run that script, and Mail opens a new message with them attached. Save it as a Quick Action or wire it into Shortcuts via the Run AppleScript action.

Inspecting an App’s Dictionary

In Script Editor choose File → Open Dictionary… and pick any app. You’ll see every class, property, and command the app exposes to scripting — an invaluable reference when you’re trying to figure out exactly how to automate it.

💡 JXA alternative: If AppleScript’s syntax feels alien, every scripting dictionary is also accessible from JavaScript via JavaScript for Automation (JXA). Open Script Editor’s language dropdown and switch to JavaScript — the same automations become callable from familiar JS syntax.

Folder Actions

A Folder Action is a workflow attached to a specific folder that fires whenever an item is added to that folder. It’s one of the oldest and most reliably useful automation primitives on macOS, and it still works beautifully today.

Attaching a Folder Action

  1. Right-click any folder in Finder.
  2. Choose Services → Folder Actions Setup…
  3. Toggle Enable Folder Actions and pick a script or Automator workflow to attach.

Example: Auto-Optimize Screenshots

Point macOS to save screenshots to ~/Pictures/Screenshots. Create an Automator Folder Action attached to that folder with these steps:

  1. Get Folder Contents (passes new items in).
  2. Scale Images — to size 2000 pixels.
  3. Change Type of Images — to JPEG with 80% quality.
  4. Move Finder Items — to ~/Pictures/Screenshots/optimized.

Every screenshot you take from this moment forward is automatically resized, re-encoded, and sorted — without you ever thinking about it again.

⚠️ Watch out: Folder Actions fire for every file dropped in, including temporary files created by other apps. Build in a guard clause (e.g. ignore filenames starting with a dot or .tmp extensions) to prevent runaway processing.

Scheduling with launchd & cron

Workflows become genuinely life-changing when they run without you. macOS offers two scheduling systems: launchd, Apple’s modern service manager that supersedes everything else, and the classic Unix cron daemon, which is still installed but no longer the recommended path.

launchd: The Modern Way

launchd is driven by small XML .plist files that live in one of several LaunchAgent directories. For per-user background jobs, drop a plist into ~/Library/LaunchAgents/. Here’s a complete example that runs the Downloads archiver script every night at 2:00 a.m.:

<?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.rayguide.archive-downloads</string>
  <key>ProgramArguments</key>
  <array>
    <string>/Users/you/bin/archive-downloads.sh</string>
  </array>
  <key>StartCalendarInterval</key>
  <dict>
    <key>Hour</key><integer>2</integer>
    <key>Minute</key><integer>0</integer>
  </dict>
  <key>StandardOutPath</key>
  <string>/tmp/archive-downloads.log</string>
  <key>StandardErrorPath</key>
  <string>/tmp/archive-downloads.err</string>
</dict>
</plist>

Load it with:

launchctl load  ~/Library/LaunchAgents/com.rayguide.archive-downloads.plist
launchctl list  | grep rayguide
# To test immediately:
launchctl start com.rayguide.archive-downloads

cron: The Classic Way

If you prefer old-school cron syntax, it still works. Edit your user crontab with crontab -e and add:

# Minute Hour DayOfMonth Month DayOfWeek Command
0 2 * * * /Users/you/bin/archive-downloads.sh
*/15 * * * * /Users/you/bin/sync-notes.sh

You may need to grant cron Full Disk Access in System Settings → Privacy & Security before it can read files inside protected folders.

Featurelaunchdcron
Apple-recommended✅ Yes❌ Legacy
Runs if Mac was asleep✅ Catches up❌ Misses it
Trigger on file change✅ WatchPaths❌ No
Trigger on network event✅ Yes❌ No
Human-readable syntax❌ Verbose plist✅ One line

Chaining Actions Together

The real power of macOS automation is composition. Each layer — Shortcuts, Automator, AppleScript, shell — can call every other layer, so complex workflows are built from small, debuggable pieces that each do one thing well.

A Real-World Chain

Imagine this everyday scenario: you receive a PDF invoice by email. You want it saved to a dated folder, logged in a spreadsheet, and acknowledged by a notification. Here’s how the layers combine:

  1. Mail Rule matches the sender and runs an AppleScript.
  2. The AppleScript saves attachments to ~/Invoices/incoming.
  3. A Folder Action on that folder calls a shell script.
  4. The shell script renames the file with the date, moves it to ~/Invoices/YYYY-MM, and appends a row to ~/Invoices/log.csv.
  5. The script finishes with osascript -e 'display notification ...' and exits.

Each piece is five to twenty lines of code, individually testable. Together they replace about ten minutes of manual filing per invoice — forever.

Patterns for Reliable Chains

  • Idempotency — running the same step twice should not corrupt data. Always check “does this file already exist?” before moving.
  • Logging — every chain should write to a single log file so you can diagnose failures weeks later.
  • Fail loudly — if any step errors, surface a notification; silent failures are the enemy of trust.
  • Keep steps small — one responsibility per script. Easier to reuse, easier to debug.
✅ Pattern: Use the shell osascript command to run AppleScript inline (osascript -e '...') and the shortcuts run command to call a Shortcut — both give you a one-line bridge between layers.

Third-Party Automation Tools

The built-in tools cover 80% of real-world needs, but a handful of third-party apps have become legendary in the Mac community for extending automation in ways Apple hasn’t.

ToolPrimary StrengthBest For
Keyboard MaestroMassive trigger library (hotkey, time, device, clipboard, USB attach)Users who want one tool to replace Shortcuts, Automator, and more
HazelSmart folder rules on steroidsAutomated filing, renaming, cleanup
BetterTouchToolCustom trackpad gestures, Touch Bar, menu barInput-driven automations
Alfred WorkflowsLauncher-based workflow builder in Alfred PowerpackKeyword-triggered scripts and search
RaycastModern launcher with script commands and extensionsDeveloper-focused command palettes
HammerspoonLua scripting of the entire window and input systemAdvanced users who want programmable macOS

You don’t need any of these to be productive — Shortcuts plus a few shell scripts will carry most people a long way. But Hazel in particular is nearly in a category of its own: its rule editor is so expressive that many professionals replace most of their folder-based automations with a single Hazel ruleset.

Best Practices

After years of building and maintaining workflows on macOS, a few principles consistently separate automations that keep working from ones that silently rot.

1. Version-Control Your Automations

Create a ~/dotfiles or ~/automations Git repository. Store your shell scripts, AppleScripts, launchd plists, and exported Shortcuts there. Future-you, on a new Mac, will thank present-you.

2. Prefer Composable Steps Over Monoliths

A 200-line AppleScript that does everything is impossible to debug. Four 50-line scripts that each do one thing can be chained, replaced, or reused independently.

3. Add Logging From Day One

Every automation should write to a predictable log location. In shell:

LOG="$HOME/Library/Logs/my-automations.log"
echo "[$(date '+%F %T')] archive-downloads: finished OK" >> "$LOG"

4. Grant Permissions Deliberately

macOS’s TCC privacy system will prompt you the first time an automation touches protected locations like Desktop, Documents, Contacts, or Full Disk. Approve those prompts explicitly and keep a note of which binaries have which permissions. When something stops working after a macOS upgrade, revoked permissions are almost always the cause.

5. Test Before Scheduling

Never schedule a script you haven’t run manually at least five times. Scheduled failures are invisible failures.

6. Build an “Undo” Mindset

Any workflow that deletes, moves, or overwrites should either keep a backup, write to a _trash/ subfolder you empty weekly, or require an explicit confirmation on the first run. Automation that destroys data is worse than no automation.

📚 Keep learning: Apple’s own developer documentation on Shortcuts, the Mac Automation Scripting Guide, and the active r/MacOS and r/applescript communities are gold mines of real workflow examples. Steal shamelessly and adapt.

Final Thoughts

Mac automation is one of the quietest, highest-leverage investments you can make in your digital life. Every workflow you build is a tiny employee that works for you — free, tireless, and perfectly consistent. Start small: pick one annoying three-minute task you did this week and automate it before you do it next week. Then do it again, and again. Within a few months you’ll have a toolkit of workflows that make your Mac feel genuinely personal — shaped around your work, not someone else’s idea of it.

Welcome to the quiet revolution. Your Mac has been waiting.