Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to merge multiple pdfs based on file names?

Posted on 2011-03-08
5
Medium Priority
?
1,822 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 8

Expert Comment

by:jawa29
ID: 35083673
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
ID: 35106445
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
ID: 35110876
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
ID: 35145542
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
ID: 38475423
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

722 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