Automatic PDF compression when files are placed in a "hot folder". A zero-touch solution for preparing PDFs for email delivery.
- Drop PDF into
~/Desktop/PDF-Inputfolder - Automatically compressed (typically 50-80% size reduction)
- Result appears in
~/Desktop/PDF-Outputwith_compressedsuffix - Original is deleted automatically
- macOS notification shows compression results
Copy and paste this command into your Terminal:
bash <(curl -fsSL https://raw.githubusercontent.com/OneLifer/pdf-compress-macos/main/install.sh)git clone https://github.com/OneLifer/pdf-compress-macos.git
cd pdf-compress-macos
chmod +x install.sh
./install.sh- Install dependencies:
brew install ghostscript fswatch- Download and copy the script:
curl -fsSL https://raw.githubusercontent.com/OneLifer/pdf-compress-macos/main/compress-pdf.sh -o /usr/local/bin/compress-pdf.sh
chmod +x /usr/local/bin/compress-pdf.sh- Download and install autostart:
curl -fsSL https://raw.githubusercontent.com/OneLifer/pdf-compress-macos/main/com.user.pdfcompressor.plist -o ~/Library/LaunchAgents/com.user.pdfcompressor.plist
launchctl load ~/Library/LaunchAgents/com.user.pdfcompressor.plistOpen /usr/local/bin/compress-pdf.sh and change the QUALITY variable:
| Value | DPI | Use Case |
|---|---|---|
screen |
72 | Minimum size, for screen viewing |
ebook |
150 | Default - balanced quality and size for email |
printer |
300 | For printing |
prepress |
300 | Maximum quality with color preservation |
Stop:
launchctl unload ~/Library/LaunchAgents/com.user.pdfcompressor.plistStart:
launchctl load ~/Library/LaunchAgents/com.user.pdfcompressor.plistRestart:
launchctl unload ~/Library/LaunchAgents/com.user.pdfcompressor.plist
launchctl load ~/Library/LaunchAgents/com.user.pdfcompressor.plistCheck status:
launchctl list | grep pdfcompressorAll operations are logged to ~/Desktop/PDF-Output/compression.log
Log format:
2024-01-15 14:30:22 - Processing: presentation.pdf (45.32MB)
2024-01-15 14:30:28 - Success: presentation.pdf -> 8.45MB (81% reduction)
2024-01-15 14:30:28 - Deleted original: presentation.pdf
To change folder locations, edit the variables at the beginning of /usr/local/bin/compress-pdf.sh:
INPUT_DIR="$HOME/Desktop/PDF-Input"
OUTPUT_DIR="$HOME/Desktop/PDF-Output"After making changes, restart the service.
launchctl unload ~/Library/LaunchAgents/com.user.pdfcompressor.plist
rm ~/Library/LaunchAgents/com.user.pdfcompressor.plist
rm /usr/local/bin/compress-pdf.shOptionally remove the folders:
rm -rf ~/Desktop/PDF-Input ~/Desktop/PDF-OutputHomebrew installation requires terminal restart:
If the installer says Homebrew was installed but needs a shell restart:
- Close the terminal window
- Open a new terminal window
- Run the installation command again:
bash <(curl -fsSL https://raw.githubusercontent.com/OneLifer/pdf-compress-macos/main/install.sh)
Service won't start:
# Check for errors
cat /tmp/pdfcompressor.errGhostscript not found:
brew install ghostscriptfswatch not found (polling mode used):
brew install fswatch
# Restart the serviceFiles are not being processed:
- Ensure the file has a
.pdfor.PDFextension - Check the log for errors
- Verify the service is running:
launchctl list | grep pdfcompressor
- macOS 10.14+
- Homebrew
- ~100MB for dependencies (Ghostscript, fswatch)