8

I have 250 pdf files in one folder that I want to merge in one document. The order does not matter. Is there a simple way of doing it?

I can use PDF-Shuffler as suggested here https://askubuntu.com/a/2805/247771 but the progam hangs for 10 minutes befor it has loaded all the pdfs.

Can I achive this maybe with an inline command like

pdftk *.pdf output mergedfiles.pdf

?

  • 3
    Your pdftk command is just missing a cat I think: pdftk *.pdf cat output mergedfiles.pdf – steeldriver Feb 24 '17 at 17:04
  • @steeldriver if you write an answer I would mark it as chekced. – Adam Mar 26 '18 at 16:15
18

I would use pdfunite. It is nice and simple. cd to your directory. Then use something like this:

pdfunite *.pdf all.pdf

(Before running, make sure you don't already have a file called all.pdf in that directory.)

  • Using pdfunite version 0.68.0 with Ubuntu 18.10, I had to use pdfunite * all.pdf. When I tried pdfunite *.pdf all.pdf, it gave me the following error I/O Error: Couldn't open file '*.pdf': No such file or directory. Syntax Error: Could not merge damaged documents ('*.pdf') . – edesz May 5 at 19:47
3
  1. sudo apt-get install gs
  2. gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=target.pdf -dBATCH xx.pdf xx.pdf xx.pdf ...
  3. you can get all filenames through ls -l *.pdf | awk command

Wish it helps . ^_^

  • On Ubuntu 16.04 I get E: Package 'gs' has no installation candidate. – MERose Aug 29 '17 at 19:42
3

Thanks to steeldriver who showed me that this is doing the job:

pdftk *.pdf cat output mergedfiles.pdf
3

You can use qpdf as pdftk is not available in ubuntu bionic:

qpdf --empty --pages *.pdf -- out.pdf

  • Worked in Ubuntu 18.04. Thanks. – parisa Jun 13 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.