FileCompressorPrivate, in-browser compression

Auto-Compressing Attachments Using Built-In Mac Automator Workflows

Updated 10 Oct 2026

Sending large files via email can be frustrating, especially when mail servers reject your messages for exceeding size limits. Writing a mac automator script to shrink email attachments solves this problem by automating the reduction process right on your device. Instead of manually resizing photos and documents every time you prepare a message, you can set up a custom workflow to handle the task in seconds.

Every file you process stays completely private because processing happens locally on your computer. You never have to worry about uploading sensitive documents, personal photos, or confidential work files to an unknown third-party cloud server.

Why Automate Email Attachment Compression on macOS

macOS includes powerful automation tools that let you string together system actions without writing complex code from scratch. By creating a custom workflow, you eliminate repetitive manual tasks and ensure your outgoing messages always comply with standard mail server restrictions.

The Security Benefit of Local Processing

Many online compression utilities require you to upload your files to a remote server. This creates privacy risks, especially when handling financial records, legal documents, or private photographs. When you use a native macOS approach, your data never leaves your hard drive. For quick web-based tasks that still prioritize privacy, you can also use Compress Image for Email directly in your browser without any server uploads.

Saving Storage and Bandwidth

Large attachments clog up your sent folder, consume valuable iCloud storage, and take longer to transmit over slow internet connections. Shrinking files before hitting send ensures smoother delivery and keeps your local mail database lightweight and organized.

Understanding Mac Automator and Folder Actions

Automator is a built-in application on every Mac that allows you to create workflows by dragging and dropping actions. You can build applications, quick actions, or folder actions that trigger automatically when specific conditions are met.

What is a Folder Action?

A folder action is a script attached to a specific folder on your Mac. Whenever items are added to that folder—such as files you intend to email—the assigned workflow automatically runs on those items. This makes it ideal for handling attachments seamlessly.

Limitations of Native Automator Image Actions

While macOS includes built-in actions to scale images, they often lack fine-tuned control over compression rates and do not handle non-image files like PDFs efficiently. Combining Automator with shell scripts or browser-based tools gives you much better results.

Step-by-Step: Creating Your Attachment Compression Workflow

Follow these steps to set up a dedicated folder that automatically shrinks any file you drop into it.

Step 1: Open Automator

  1. Open Finder and navigate to your Applications folder, or press Command + Space to open Spotlight and type "Automator".
  2. Open the Automator app.
  3. When prompted to choose a document type, select Folder Action and click Choose.

Step 2: Select the Target Folder

  1. At the top of the workflow window, look for the dropdown menu labeled Folder Action receives files and folders added to.
  2. Select Other... and create a new folder on your Desktop named something like "Email Ready".
  3. Click Choose to link this folder to your workflow.

Step 3: Add the Shell Script Action

  1. In the left-hand library sidebar, click on Utilities.
  2. Drag the Run Shell Script action into the workflow area on the right.
  3. Set the "Shell" dropdown to /bin/zsh and the "Pass input" dropdown to as arguments.

Step 4: Write or Paste the Automation Logic

Replace the default placeholder text in the shell script box with a command that processes your files. For advanced image processing, you can call command-line utilities like sips (Scriptable Image Processing System):

for f in "$@"
do
  # Resize images to a maximum width of 1200 pixels while maintaining aspect ratio
  sips -Z 1200 "$f"
done

Note: Menu paths and interface labels may differ slightly depending on your specific version of macOS. If you prefer a visual interface rather than terminal commands, you can drag your files into a local browser tab running a client-side utility before attaching them to your email client.

Comparing Attachment Reduction Methods

Method Privacy Level Speed Ease of Setup Handles PDFs
Mac Automator Script 100% Local Fast Intermediate Requires add-ons
Cloud Compressors Low (Server Upload) Variable Easy Yes
Browser-Based Local Tools 100% Local Instant Very Easy Yes
Manual Preview Resizing 100% Local Slow Easy No

Common Mistakes and How to Fix Them

Even with a straightforward setup, small configuration errors can prevent your workflow from functioning properly.

Mistake 1: Folder Actions Are Disabled Globally

If you drop a file into your designated folder and nothing happens, Folder Actions might be turned off in your system settings.

  • The Fix: Right-click your target folder in Finder, go to Services, and select Folder Action Setup... Ensure that "Enable Folder Actions" is checked.

Mistake 2: Overwriting Original Master Files

Running scripts like sips directly modifies the source file in place. If you drag your only high-resolution family photo into the folder, you might lose the master copy.

  • The Fix: Modify your script to duplicate files into a separate "Compressed Output" directory before applying compression commands.

Mistake 3: Attempting to Compress Unsupported File Formats

Image scaling tools will fail or throw errors if you drop a Microsoft Word document, archive, or unsupported video format into an image-only workflow.

  • The Fix: Filter your script to check file extensions, or use a versatile client-side tool that safely handles multiple file types in your browser.

Quick Checklist for Reliable Attachment Automation

  • Created a dedicated staging folder on your Mac.
  • Opened Automator and selected "Folder Action".
  • Linked the workflow to your staging folder.
  • Configured the Run Shell Script action with correct parameters.
  • Verified that Folder Actions are enabled in system settings.
  • Tested the workflow with a sample duplicate image file.

Frequently asked questions

Will an Automator script reduce the quality of my photos?

Yes, shrinking image dimensions and compressing files reduces visual data to save space. However, setting a reasonable pixel limit like 1200 pixels keeps images looking sharp on computer and phone screens while significantly lowering file size.

Are my files uploaded to the internet when using Automator?

No, Automator runs entirely locally on your Mac's hardware using built-in macOS commands and utilities. Your data never leaves your device, ensuring complete privacy.

Can I use this script for PDF documents as well as images?

The default macOS `sips` command-line tool only handles standard image formats like JPEG and PNG. To compress PDFs, you would need to incorporate a specialized command-line utility or process them through a secure local browser tool.

Why is my Folder Action workflow not triggering when I add files?

Folder Actions must be explicitly enabled in macOS. Right-click your target folder in Finder, select Services, open Folder Action Setup, and verify that the master toggle is turned on.

How do I stop the script from overwriting my original files?

You can update your shell script code to copy incoming files to a secondary destination folder before executing the compression command on those copies.

Related articles

Free tools