Reputation: 23879
I am trying to make it easier to combine more than just a few pdf files with pdfjam:
pdfjam c1.pdf c2.pdf ... c100.pdf -o outfile.pdf
Here we got 100 files that should be merged. How can I shorten this command by using some kind of sequence command or reading out the files from the folder or something like this? I do not want to write all 100 file names by hand.
What does not work, but still explains what I am looking for is
pdfjam c{1..100}.pdf -o outfile.pdf
Upvotes: 0
Views: 447
Reputation: 4112
You can try this
echo pdfjam c{1..4}.pdf -o -o outfile.pdf | bash
or
echo -n "pdfjam " ;for (( i=1; i<=100; i++)); do printf "c${i}.pdf "; done ; echo "-o outfile.pdf"
user@host:/tmp/pythontest$ echo -n "pdfjam " ;for (( i=1; i<=4; i++)); do printf "c${i}.pdf "; done ; echo "-o outfile.pdf"
pdfjam c1.pdf c2.pdf c3.pdf c4.pdf -o outfile.pdf
user@host:/tmp/pythontest$ echo -n "pdfjam " ;for (( i=1; i<=10; i++)); do printf "c${i}.pdf "; done ; echo "-o outfile.pdf"
pdfjam c1.pdf c2.pdf c3.pdf c4.pdf c5.pdf c6.pdf c7.pdf c8.pdf c9.pdf c10.pdf -o outfile.pdf
Upvotes: 1