scripts

Various scripts for UNIX-like systems
git clone https://git.tronto.net/scripts
Download | Log | Files | Refs | README

mergepdf (413B)


      1 #!/bin/sh
      2 
      3 # Merge multiple pdf files into one
      4 # Requires: gs
      5 
      6 # Usage: mergepdf [-o outname] file1.pdf file2.pdf ...
      7 
      8 outname=merged.pdf
      9 
     10 usage() {
     11 	echo "Usage: mergepdf [-o OUTFILE] file1.pdf file2.pdf ..."
     12 }
     13 
     14 while getopts "o:" opt; do
     15 	case "$opt" in
     16 		o)
     17 			outname="$OPTARG"
     18 			;;
     19 		*)
     20 			usage
     21 			;;
     22 	esac
     23 done
     24 shift $((OPTIND - 1))
     25 
     26 gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="$outname" "$@"