hi i have a few thousand single paged pdf files in one folder and one single paged pdf(its file name is 2.pdf). I want to merge all the pdfs in the folder with the 2.pdf file. at the end should have all the pdfs in the folder with 2pages and the second page being the contents of 2.pdf. Please assist on this. thanks
Asked
Active
Viewed 2,140 times
-2
-
possible duplicate of [merge / convert multiple pdf files into one pdf](http://stackoverflow.com/questions/2507766/merge-convert-multiple-pdf-files-into-one-pdf) – user000001 Dec 10 '13 at 13:54
-
1@user000001 that a different (more complex) question – Édouard Lopez Dec 10 '13 at 14:08
1 Answers
3
So for all PDF files of the current directory, except 2.pdf
, we merge x.pdf
with 2.pdf
as a new file called new-x.pdf
. So we can use the command given in merge / convert multiple pdf files into one pdf to do this:
cover="2.pdf";
outputDir="output-pdfs/";
mkdir "$outputDir";
for f in *.pdf; do
[[ "$f" == "$cover" ]] && continue # skip the cover PDF
pdfunite "$f" "$cover" output-pdfs/new-"$f".pdf;
done

Community
- 1
- 1

Édouard Lopez
- 40,270
- 28
- 126
- 178