I have to merge a lot of pdf files and I numbered them from 1 to 100 or more. I want to merge specific files.
Can I merge them doing something similar to this?
pdftk [1-20].pdf cat output out.pdf
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityIf I understand correctly, in your example you want to merge the first 20 pdf files, i.e. the files with names from 1.pdf
to 20.pdf
. You can do that using brace expansion, so the command you need to run is:
pdftk {1..20}.pdf cat output out.pdf
In essence, {1..20}.pdf
is expanded by the shell to 1.pdf
, 2.pdf
, 3.pdf
, ..., 20.pdf
, so it's the same as running (the ellipses signify the intermediate files):
pdftk 1.pdf 2.pdf 3.pdf ... 20.pdf cat output out.pdf