Thursday, September 27, 2012

Ubuntu PDF merge one liner

These are always the best

$ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output_file.pdf  `ls -x *pdf | sort`

The ls -x incantation ensures everything is on one line to be feed to gs. This really handy when scanning multipage documents so if it jams along the way your entire pdf isn't lost.