Last active
August 29, 2015 14:09
-
-
Save jaygooby/78d5642154cd213b6f5b to your computer and use it in GitHub Desktop.
Combine multiple pdfs, potentially with spaces in their name, using pdftk and xargs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Props to http://www.lornajane.net/posts/2011/combining-pdf-files-with-pdftk | |
# found via http://stackoverflow.com/questions/19122448/bash-escaping-spaces-in-filename-in-variable#comment42365877_19122448 | |
# | |
# here the sort is used because the pdfs are named something like page 01.pdf page 02.pdf and the -z means the whitespace | |
# doesn't cause any issues | |
find ./somepath -name "*.pdf" -print0 | sort -z | xargs -0 -J % pdftk % cat output out.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment