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


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

5 Answers 5


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.)

  • 2
    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
    Commented May 5, 2019 at 19:47
  • Using pdfunite *.pdf all.pdf , which works great, I got Syntax Error pdfunite I/O Error: Too many open files which could be solved with ulimit -S -n 2048
    – GitClaus
    Commented Apr 16 at 16:26

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

pdftk *.pdf cat output mergedfiles.pdf
  • 1
    I have Kubuntu 19.10. this pdftk does not work.
    – rob grune
    Commented Jan 25, 2020 at 6:59
  • @robgrune pdftk in recent Ubuntu versions is a snap, which only works in your home folder, but fails silently elsewhere - like /tmp which is where I use it the most. Because the failure is silent (a particularly dumb misfeature of snaps) it's caught me out more than once, but a proper installation has worked on all (X|K)ubuntu versions for me for many years. Not also that you can't overwrite an output file in the same folder this way, but that error is clear
    – Chris H
    Commented Jun 7, 2023 at 14:27
  • @ChrisH Installing java version of pdftk whith sudo apt install pdftk-java with version 3.2.2-1 Works with Ubuntu 22.04 LTS
    – itbojen
    Commented Jan 26 at 15:52
  • @itbojen yes, I use that. The reason I no longer use Ubuntu for clean installs is the switch from standard behaviour to anti-user modes (software should never refuse silently to do what it's told - if that's a feature of snaps as it seems to be, it means the entire snap system is fundamentally flawed), requiring workarounds. The upgrade from 20.04 to 22.04 is even worse, uninstalling packages (Firefox) that I'd made an effort to install properly , and replacing them with snaps. On my work machine I'll probably do a clean install of Debian instead of upgrading Ubuntu rather than fight snaps
    – Chris H
    Commented Jan 26 at 16:38
  • This preserves TOC information! I merged a bunch of pdf which all had their own table of contents infomation. This command used all of those smaller TOCs to create one large TOC allowing the entire combined document to be navigated, which is enormously helpful! FWIW: Kubuntu 22.04
    – stephan
    Commented May 31 at 4:03

You can use qpdf as pdftk is not available in Ubuntu Bionic:

qpdf --empty --pages *.pdf -- out.pdf
  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
    Commented Aug 29, 2017 at 19:42

You can use pdftools:

pdftools --input-dir dir_with_pdfs --output output.pdf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .