PDF-Dateien mit PDFTK zusammenführen

751
Ramin Melikov

Ich habe ein Verzeichnis mit PDF-Dateien, das folgendermaßen aussieht:

2016_AAA_SomeRandomText1.pdf

2016_BBB_SomeRandomText1.pdf

2016_AAA_SomeRandomText2.pdf

2016_BBB_SomeRandomText2.pdf

2016_AAA_SomeRandomText3.pdf

2016_BBB_SomeRandomText3.pdf

usw...

Hinweis: SomeRandomText ändert sich, ist jedoch paarweise.

Ich möchte also den Ordner über die Windows-CLI mit einer FOR-Schleife durchgehen und für jedes SomeRandomText-Paar mit PDFTK eine PDF-Datei erstellen. Die Ausgabe sieht also so aus:

2016_AAA_SomeRandomText1.pdf + 2016_BBB_SomeRandomText1.pdf = 2016_SomeRandomText1.pdf

2016_AAA_SomeRandomText2.pdf + 2016_BBB_SomeRandomText2.pdf = 2016_SomeRandomText2.pdf

2016_AAA_SomeRandomText3.pdf + 2016_BBB_SomeRandomText3.pdf = 2016_SomeRandomText3.pdf

usw...

Folgendes habe ich bisher (vorausgesetzt, ich arbeite in C: \ user \ pdfs):

FOR /R %I IN (*.pdf) DO pdftk 
0

1 Antwort auf die Frage

-1
Jeff Dodd

Ich erzähle Ihnen, wie ich es in bash gemacht habe, und vielleicht können Sie es übersetzen.

Ich benutze pdfunite(etwas direkter als pdftk), aber sobald Sie die Syntax herausgefunden haben, ist das einfach genug.

for AFILE in `ls 2016*AAA*.pdf` ## For each of the files starting with 2016_AAA do BFILE=`echo $AFILE | sed -e 's/AAA/BBB/'` ## I use stream editor to replace the AAA with BBB and define the ## new file name. You can probably use SUBSTITUTE in Win pdftk $AFILE $BFILE cat output OUTPUT-$AFILE ## This will combine $AFILE and BFILE into OUTPUT-AFILE done 

Hoffentlich gibt Ihnen das einen Anfang.