• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1025
  • Last Modified:

Merge PDFs together based on their filename

Hello,

Does anybody know a way (perhaps using JavaScript) to merge PDFs together based on their filename?

I have created several PDF files (extracting from a large file) with student timetable on it and named the files with their student ID and page number (some are 2 pages and some are only one page):

012345 - page1.pdf
012345 - page2.pdf
011112 - page1.pdf
022223 - page1.pdf
022223 - page2.pdf

I need to merge the files together based on the filename, i.e.

012345 - page1.pdf
012345 - page2.pdf

MERGED into a single file (based on the first 6 characters of the filename).

There is over a 1000 files therefore would take a long time to do manually.

Any ideas (I am sure this can be done using the JavaScript Console however I am not sure how). I have the latest copy of Adobe Acrobat.

Thanks,
Gary
0
Gary Mellor
Asked:
Gary Mellor
  • 5
  • 2
1 Solution
 
dsackerContract ERP Admin/ConsultantCommented:
You may want to look at this Experts Exchange link:

http://www.experts-exchange.com/Web_Development/Document_Imaging/Adobe_Acrobat/Q_28284918.html

The solutions in that link involve calling the utilities from a Windows .bat file. But the examples are there, too.
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
Hi Gary,

The key to the solution is this EE article:
http://www.experts-exchange.com/Web_Development/Document_Imaging/A_10745-How-To-Combine-Merge-Append-TIFF-Files-in-Batch-Mode.html

That article is about TIFF files, but with minor modifications works for PDF files. Here are two threads that discuss it:
http://www.experts-exchange.com/Software/Misc/Q_28337712.html
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28604770.html

I'll be happy to assist if you need help getting it to work. I'm leaving for an hour or so now but will check back in with you as soon as I return. Regards, Joe
0
 
Gary MellorAuthor Commented:
Hi Joe

Thanks for your help. I have been able to get the script to run with IrfanView however the quality of the merged pdf is poor (it becomes a flat file image of poor quality). I have looked at pdftk - this is a better program for this task. Merged files retain the text and layers and the quality is better. I cannot however work out how to adapt the script to use the pdftk program (see attached error screenshot). Please can you help me to adapt the attached script file?

Many thanks,
Gary
PDF-Merge--IrfranView-.ahk
PDF-Merge--test2-.ahk
errorscreenshot.jpg
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Joe Winograd, Fellow&MVEDeveloperCommented:
Hi Gary,

I've had a lot of experience with PDFtk and can probably get the script to work with it. For example, here's a thread where we switched from IrfanView with the multipdf option to PDFtk:
http://www.experts-exchange.com/Database/Software/FoxPro/Q_28325659.html

I'll look at it later tonight and get back to you. Regards, Joe
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
Hi Gary,
I looked at my code tonight and developed an approach for how to do it with PDFtk. I'll send you a message via EE's Messaging System to discuss it further. Regards, Joe
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
For anyone interested in this thread, I have developed a program to perform the function that Gary requested. It uses the PDFtk "cat" operator rather than the IrfanView "multipdf" operator. The approach is, essentially, a combination of the technique in How To Combine-Merge-Append a Large Batch of TIFF Files to combine files based on a matching prefix and the technique in How to Combine-Merge PDF Files in Many Subfolders to build up the "cat" input parameter for a call to PDFtk. An important note associated with this approach is the Windows limitation of 8,191 characters in a command line call. See my comment at the latter article that explains this in detail.

At this point, I am not posting the source code, but am happy to provide the compiled program (CombinePDFsBasedOnFilenames.exe) to any EE member who is willing to act as a beta tester for it (please send me a message via the EE Messaging System if you are interested). The compiled program is a stand-alone executable, but also requires PDFtk Server to be available (you must download that yourself from the PDFtk website — both pdftk.exe and libiconv2.dll). Regards, Joe
0
 
Gary MellorAuthor Commented:
There is some commercial software for $99 from Evermap that also perform this task:

http://www.evermap.com/autosplit.asp
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
Gary,

Thanks for the heads-up on my competition. :)

Thanks, too, for letting me know that my program processed your 2,000+ files successfully — that's great news! And a final thanks for being a beta tester and reporting issues. Regards, Joe
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now