I was trying to compress a folder on my Mac and was annoyed that it kept including hidden metadata files like .DS_Store and __MACOSX folders in the zip. While these are harmless on a Mac, they appear as “junk” files to everyone else and are simply unnecessary.
I figured there must be a solution, so I went looking. I didn’t want to use the Terminal every time I needed to zip a folder, and I wasn’t interested in downloading a third-party utility for such a seemingly simple task.
After some experimentation with Gemini, I found a way to build a native “Clean Zip” tool directly into the macOS Finder using Automator! It’s a set-it-and-forget-it solution that works beautifully.
The Problem with Default Compression
The standard right-click “Compress” option in Finder is designed for Mac-to-Mac transfers. It preserves Mac-specific file attributes, which results in those extra hidden files. While you can technically use the zip command in the Terminal to exclude them, it’s a manual, repetitive process that breaks the flow of working in the Finder.
The Solution: A Custom Quick Action
By using macOS’s built-in Automator app, you can create a “Quick Action” that appears in your right-click menu. This allows you to perform a “clean” compression with a single click, using the power of a script without having to deal with a command line.
Step 1: Set up the Automator Workflow
- Open Automator (found in your Applications folder).
- Select New Document and choose Quick Action.
- At the top of the workflow, set the following:
- Workflow receives current:
files or folders - in:
Finder
- Workflow receives current:
- In the search bar on the left, find “Run Shell Script” and drag it into the main window.
- Change the “Pass input” dropdown to as arguments.
Step 2: Add the Magic Script
Delete any text in the script box and paste the following:
for f in "$@"; do
cd "$(dirname "$f")"
zip -r "${f##*/}.zip" "${f##*/}" -x "*.DS_Store" -x "__MACOSX*"
done
This script tells macOS to:
- Navigate to the folder containing your file.
- Create a ZIP named after your file.
- Crucially: Exclude any
.DS_Storeor__MACOSXfiles from the archive.
Tip: This script is designed to also handle multiple items at once. Whether you select one folder or highlight ten different files, the “Clean Zip” action will create individual, junk-free archives for every item in your selection.
Step 3: Save and Use
- Go to File > Save and name it “Clean Zip”.
- Now, simply right-click any file or folder in Finder.
- Navigate to Quick Actions > Clean Zip.
The Result
You now have a custom, native tool that creates clean archives ready for any operating system. No third-party apps, no Terminal windows, and no “junk” files stuffed in there. It’s a small workflow tweak that makes a huge difference in productivity, and makes me very happy!