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
Gary MellorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.