3

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

1 Answer 1

8

If 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

You must log in to answer this question.

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