Created
September 20, 2016 08:55
-
-
Save lee2sman/21cd9ef534859cfb3365fd425dee3270 to your computer and use it in GitHub Desktop.
commandline tool to batch combine pdf files in current directory, using ghostscript
This file contains 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 | |
# | |
# PDF Combiner | |
# Combines all files ending in .pdf in current directory | |
# cc0 Lee2sman 2016 | |
# | |
# DEPENDENCIES: gs | |
# USAGE: ./pdfmerge output.pdf | |
# Make executable and put this in your PATH to be able to run it with pdfmerge output.pdf | |
hash gs &> /dev/null | |
if [ $? -eq 1 ] #Checks to see if ghostscript is installed | |
then | |
echo >&2 "gs (ghostscript) must be installed to use pdfmerge." | |
echo "On Mac: brew install gs" | |
echo "More info at ghostscript.com/" | |
exit 1 | |
elif [ $# -eq 0 ] #Exits if missing output name | |
then | |
echo "No output specified. USAGE: pdfmerge output.pdf" | |
exit 1 | |
else | |
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$1 *.pdf | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment