Solved

How to merge multiple pdfs based on file names?

Posted on 2011-03-08
5
1,455 Views
Last Modified: 2015-04-11
Hi,

I have about 10 folders containing some pdfs that I need to merge based on the file name. The naming convention is like "acctnumber_12345.pdf" and each acctnumber has multiple pdfs associated with it. I want to merge everything for each account under a new name convention "acctnumber.pdf". Is there a script or any easy way to get it done? FYI, I'm using a Windows OS and I have thousands of files.
0
Comment
Question by:bpatton_psr
5 Comments
 
LVL 8

Expert Comment

by:jawa29
Comment Utility
Hi bpatton_psr

The first question is... Do you own a copy of Acrobat Pro?

If the answer is yes then you have an easy solution, well easy but a little time consuming.

You can open one of the files in Acrobat Pro and then Select Document\Insert Pages\From File (Shift + Ctrl + I) From this window you can multi select the files you want to merge, on the next screen select where in the document you want them to go (normally at the end).

Job Done

Your other option is to go for something like activePDF http://www.activepdf.com/products/

Their script to merge files
http://www.activepdf.com/support/knowledgebase/viewKb.cfm?id=10678&tk=sp

Jawa29

0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, using PDFTK:
http://www.pdflabs.com/docs/pdftk-cli-examples/

you can run
pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf

to concatenate 1.pdf, 2.pdf, and 3.pdf as 123.pdf

To help you script this further, I'll need more details on what your files are.  Please provide some exact file names before and after, and I'll knock up a script.

Regards,

Rob.
0
 

Accepted Solution

by:
bpatton_psr earned 0 total points
Comment Utility
Here's what we did:

@echo off 

for /f "tokens=1,2 delims=_" %%a in ('dir *.pdf /b') do ( 
md "%%a" 2>nul 
move "%%a_%%b" ".\%%a\" >nul 
) 
for /f "delims=" %%a in ('dir /a:d /b') do ( 
copy /b "%%a\*.*" "%%a.pdf" 
) 

Open in new window

0
 

Author Closing Comment

by:bpatton_psr
Comment Utility
Was looking for a batch script. We had thousands of PDFs and we found this script online. Modified it a little bit to our solution. Worked! Thanks to all for suggestions though.
0
 

Expert Comment

by:KHMaddox
Comment Utility
bpatton_psr
I am having the same issue but I have no experience creating or using scripts.
Any advice how to accomplish this or do you perhaps know of a program that does this?
-kitmaddox@yahoo.com
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now