Mac OS X 10.4 Tiger

Somewhat hidden in the /Library folder, there is a python script which can be used to merge files on the command line. This is presumably applied also by the corresponding Automator workflow, however I prefer the command line:

/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py --help

gives you a comprehensive overview about what join.py can do. Make an alias in your ~/.profile if you use this more often.

Problem: join.py uses CoreGraphics’s CGPDFDocument APIs, therefore hyperlinks in the PDF documents might not survive the merging with join.py. If this is important, use GhostScript. Example:

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=result.pdf ?source files?

Note that GhostScript does not come with the operating system but is part of the MacTeX standard installation. Or use MacPorts to install it.

On recent versions of macOS, there is a command

/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/MacOS/join

with the same functionality built on the PDFKit framework. Usage: join [--output <file>] [--shuffle] [--verbose]

Yet another alternative is Adobe’s online PDF merge tool (welcome PC users). Not a command-line thing indeed, however I recently was asked by a millennial «what is a command line?» and the title of this page contains the word easy.