How to join PDF files in Mac on Terminal?

In Mac, you can use Preview to join multiple pdf files into a single pdf file. A more convenient way is to join/merge multiple pdf files from command line on Terminal. More recent Mac OS X versions already have Python script to merge multiple pdf files into a single pdf file. Here is how to use the Python script.

The Python script that joins multiple pdf files is located at

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

Note the blank space in the “Combine PDF Pages.action” directory. All you need to use it to merge two pdf files “page1.pdf” and “page2.pdf into “pages.pdf” is to use the script like

/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py -o pages.pdf page1.pdf page2.pdf

That is it. It is that simple. You dont even have to spell out the names of multiple pdf files. You can also simply use *.pdf to merge all pdf file like this.

/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py -o book.pdf *pdf

If you think you will forget the location of the Python script, you can also create soft link to the Python script and use it like any other Linux commands