Add a page to the end of a bunch of PDF files

Prepper

Well-known member
I have 469 PDF text files that I need to add 1 ID page to the end of each file. I have 469 individual ID pages. Is there a way with Acrobat Pro DC to batch this? Or some other means to do it?
Any input appreciated,
Thanks
 
Tools > Pages > More Insert Options > Insert blank Page (Ctrl+Shit+Q on PC).
You should be able to create an action from that and then have it do it to every file in a folder.
 
I'm not adding the same ID page to each file, I have 469 different ID pages. Each ID page goes to a specific file. I'll look at that option closer tomorrow, thanks.
 
How are the files named? What is the distribution of page counts (e.g., all 4 pages, 100 x 2 pages and 369 x 3 pages, or more diverse than that)? Do you have access to OS X and/or Linux?
 
Yes, very diverse, have 469 books, varying page counts, need to add a 1 page ID at end of each one, so we have 469 single page ID files. Yes OS X.
 
The book files are named with date codes like 65-1024.pdf and the ID pages are "ITL Id Title blocks_1.pdf", numbered 1-469.
 
Does "ITL Id Title blocks_1.pdf" need to be appended to a PDF whose name begins with "1-" or is there some other way one would know exactly how the files are to be paired up by only looking at the file names? Is another source required for this information - like a spreadsheet?
 
Yes, appended, no way to tell by filename, but they are in list order, first book in list goes with 1, 2nd with 2, etc.

I created the Id pdfs by exporting them from an InDesign data merge file. If I could have named those with the date name also I suppose that would have helped but don't know if that's possible.
 
Yes, appended, no way to tell by filename, but they are in list order, first book in list goes with 1, 2nd with 2, etc.

I created the Id pdfs by exporting them from an InDesign data merge file. If I could have named those with the date name also I suppose that would have helped but don't know if that's possible.

https://colecandoo.com/2013/07/13/br...-pdfs-that-is/

https://colecandoo.com/2015/09/04/da...now-a-reality/

http://prepression.blogspot.com.au/2...ile-Names.html


Stephen Marsh
 
Last edited:
Thanks Stephen for the help, I used the "now a reality" one.

Ok, so now I have all the single page ID PDFs named with the same datecode as the original book PDFs I want to append them to the end of. Book PDFs named "DUT65-1212 Investments BCM.pdf" and the ID PDFs as "DUT65-1212.pdf" Guess all I need now, still, is a way to automatically append the IDs onto the Books automatically.
 
Here's a solution with Acrobat javascript using the attached files. It is not thoroughly tested, so check the results very carefully.

I'm guessing it's not possible for the script to know in advance what all the filenames are by any simple convention (e.g., named something static followed by a number in the range 1-469), since your example has "1212" in the name. One of the biggest challenges with Acrobat javascript automation is working within its security restrictions. Acrobat cannot enumerate all of the file names, so it has to know in advance somehow.

For that reason, this is a two step process that starts with a bash script. Place the listfilenames.command file in a directory containing all 938 PDFs (and no other files), then double-click it to execute. It will list the contents of the directory and save it to a file named "filenames.txt." Now we have a file that the Acrobat javascript knows the name of and can read, and it contains the names of all of the files.

Now open Acrobat's javascript debugger (press command-J). You may need to enable javascript, javascript debugger, and interactive console in Acrobat's preferences first. In the console area at the bottom remove any existing text and replace it with the javascript code copied from "Acrobat javascript.txt." Then select the entire script in the console area and press shift+enter to execute (I think it has to be shift+enter, the key in the numpad, not the return key).

It will ask you to open a PDF file. Pick any PDF in your working directory. It doesn't matter which one - Acrobat won't do anything special with that particular file - this is only so the script can discover the directory containing all of the PDFs.

Now the javascript will open the filenames.txt file from that directory and thereby discover the names of all the files in the directory.

It then considers only PDF files whose name contain a space (you should have 469 of them). For each file whose name contains a space ("DUT65-1212 Investments BCM.pdf"), it will look for a PDF file with a name identical to the part before the first space ("DUT65-1212.pdf"). If there is such a file, it will save a new pdf that is a concatenation of the two, named like the first file with "A-" added to the beginning ("A-DUT65-1212 Investments BCM.pdf").
 

Attachments

  • AcrobatJavascript.zip
    831 bytes · Views: 415
Kyle, can't say thanks enough, man, you saved the day, or the week I should say! It worked just great, only issue was it wouldn't process more than 50 at a time, after first 2 tries and it stopping on 50, I just did them in groups of 40 and got the job done.
 
Kyle, also wanted to ask, it's safe to assume that the content of the 2 files is safe right and any potential mixups that might happen would just be the wrong files getting merged? I can check the first and last pages pretty quick to verify but not everything in between.
Thanks again.
 
You're welcome! Yes, the errors to watch out for are incorrect pairing. If I made a bad assumption about your filenames, you may get an incorrect result (though it should match the behavior I described, barring any bugs).

Fortunately, the code does not have to copy individual page elements. It tells Acrobat to merge the documents, so content within a given page should not change and it should be as safe in that regard as when you select "insert pages" from the Acrobat tools. I do a lot of PDF rearrangement and errors like that have been very rare in my experience. Usually one of the PDF files has some bugs in it before the merge, or something weird happens with a font that was subset in both PDFs (haven't seen that one in a long time thankfully).

The 50 document limit is very strange. Acrobat javascript can sometimes be like a freight train running downhill without brakes. The code may be trying to forge ahead before the last action is actually finished. I would have expected an error like that to happen when it tried the second document, though, not the 51st. I'll take a look next week and see if I can replicate the behavior.
 
I only tried twice and it stopped on the 50th one both times so I just went with 40 count groups from there. Was trying to do all 465 with those first 2 attempts. Did double check them all and found no issues with the pairing up.
 
I wasn't able to overcome the problem, though I only tried for about twenty minutes. It seems like a bug in the Acrobat DC javascript engine. If you have Acrobat 11 (you can probably install it with your CC subscription if not), it does not stop after 50 documents. Acrobat has a 50 open document limit, so I thought for sure it has something to do with that, but if I have it write the number of open documents to the console between documents, it stays zero.
 

PressWise

A 30-day Fix for Managed Chaos

As any print professional knows, printing can be managed chaos. Software that solves multiple problems and provides measurable and monetizable value has a direct impact on the bottom-line.

“We reduced order entry costs by about 40%.” Significant savings in a shop that turns about 500 jobs a month.


Learn how…….

   
Back
Top