Techie Things

A blog with tech recipes and other technical information by jmiguel.

1-Minute Read

I had the need to concatenate several PDFs into just one. A bunch of music scores for my band I want to keep on the ipad as a single file instead dozens of separate files.

I was looking for options and there are a lot of them: pdfunite, pdftk, ImageMagic’s convert (convert inputFile1.pdf inputFile2.pdf outputfile.pdf should do it, but it didn’t worked for me. Even it’s supposed you can select the pages you want for any file: convert inputFile1.pdf[2] inputFile12.pdf[3,6] outputFile.pdf). And of course, there are a lot of GUI options and online converters.

But at the end, what have worked for me has been GhostScript, using this simple command:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=outputFile.pdf -dBATCH inputFile1.pdf inputFile2.pdf

or just

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=outputFile.pdf -dBATCH *.pdf

for all files in current directory.

And of course you could put that line into a shell function like:

function combinePdf { 

so you don’t have to remember the full command. But for any reason (shell expansion, I guess, but I have no time now to check it) that doesn’t work.

Recent Posts