Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@karthikraman
Created June 8, 2015 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karthikraman/ebc15ad05b1257aa8123 to your computer and use it in GitHub Desktop.
Save karthikraman/ebc15ad05b1257aa8123 to your computer and use it in GitHub Desktop.
Join PDF files
#!/bin/bash
if [[ $# -eq 0 ]]
then
echo "Usage: `basename $0` <output file> <input files>"
exit 1
fi
ofile=$1
if [[ -f $ofile ]]
then
echo "Output file $ofile already exists; cowardly refusing to overwrite. Quitting!"
echo "Usage: `basename $0` <output file> <input files>"
exit 1
fi
shift
echo "Joining files:"
echo "--------------------------------"
for x in $*
do
echo $x
done
echo "--------------------------------"
echo -ne "to: " $ofile ...
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$ofile $*
echo DONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment