Skip to content

Instantly share code, notes, and snippets.

@macintux
Created December 24, 2013 22:57
Show Gist options
  • Save macintux/8118573 to your computer and use it in GitHub Desktop.
Save macintux/8118573 to your computer and use it in GitHub Desktop.
Consolidating PDFs from the command line in MacOS X

Assuming you've created a text file named "ordered" with the PDFs in the sequence you'd like to create:

$ cp /System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py /usr/local/bin/join-pdfs

$ perl -e '$first = <STDIN>; chomp $first; while(<STDIN>) { $index++; $intmdt = "foo$index.pdf"; chomp; system("join-pdfs -o $intmdt $first $_"); $first = $intmdt; }' < ordered

Now you'll have a host of foo<int>.pdf files; the last one is the one you want to rename to something useful, then rm foo*.pdf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment