Skip to content

Instantly share code, notes, and snippets.

@algal
Last active February 16, 2021 02:00
Show Gist options
  • Save algal/8d60dc66e185cbf512482f259db4d500 to your computer and use it in GitHub Desktop.
Save algal/8d60dc66e185cbf512482f259db4d500 to your computer and use it in GitHub Desktop.
join PDFs on macOS from the command line with zero dependencies
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "usage: $0 output_pdf_path input_path1..."
echo
echo "This script joins the PDFs at input_path1, input_path2, etc."
echo "into one pdf at output_pdf_path"
echo
echo "Known good: macOS 11.1, and below for many versions"
echo
exit 1
fi
script_path="/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py"
command -v "$script_path" >/dev/null 2>&1 || { echo >&2 "I require $script_path but it's not there. macOS has probably changed too much for me to be useful. Aborting."; exit 1; }
exec "$script_path" -o "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment