Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

9/27/2019 Adobe Acrobat: How to batch to combine multiple pdf files?

- Super User

Adobe Acrobat: How to batch to combine


multiple pdf files?
Asked 7 years, 7 months ago Active 1 year, 1 month ago Viewed 44k times

I have 3 folders:

9 Folder 1
Folder 2
Folder 3

In each folder I have 5 pdf files:


10
Folder 1
file1.pdf
file2.pdf
Folder 2
file1.pdf
file2.pdf
Folder 3
file1.pdf
file2.pdf

I want that in each folder to have a combined file of those two files:

Folder 1
binder.pdf
Folder 2
binder.pdf
Folder 3
binder.pdf

Any idea? Don't tell to do it manually. This case is just to explain you my problem. Think that I have
hundreds of folders. :) Maybe I can use another tool instead of Adobe Acrobat?!

pdf adobe-acrobat

asked Feb 14 '12 at 13:00


Andrei Andre
46 1 2 3

What exactly do you mean by "have a combined file of those two files"? Would concatenate and merge these
two files into 1 PDF work for you? – Kurt Pfeifle Feb 23 '12 at 23:03

Adobe Acrobat or Adobe Acrobat Reader? – wmz Aug 24 '12 at 23:13

@AndreiAndre Many good solutions were posted to your question. Maybe you could choose the one which fits
all your needs and mark it as accepted. – nixda Feb 11 '13 at 9:35

https://superuser.com/questions/389760/adobe-acrobat-how-to-batch-to-combine-multiple-pdf-files 1/6
9/27/2019 Adobe Acrobat: How to batch to combine multiple pdf files? - Super User

8 Answers

You can do this with a short batch file and pdftk.exe (not pdftk Builder which is the GUI version).
There is no need to install anything.

12 Preparation

download & extract pdftk with UniExtract


Open ..\pdftk\bin* and copy pdftk.exe and libiconv2.dll to a folder of your choice
create a new text file and paste the following code

@echo off
setlocal enabledelayedexpansion
FOR %%A IN (%*) DO (set command=!command! %%A)
pdftk.exe %command% cat output "%~dp1binder.pdf"

Save it as merge@pdf.cmd in the same folder as pdftk.exe and libiconv2.dll

create a shortcut of this .cmd and place it in your sendto folder ( Win + R » shell:sendto)

Usage

Go to a folder with some PDF files and select as many PDFs as you want
Right-click them and choose the shortcut you just created
a new binder PDF in the same folder will be created where all selected PDFs are merged into
one

Update: Version which uses current folder name as file name for generated pdf
https://superuser.com/questions/389760/adobe-acrobat-how-to-batch-to-combine-multiple-pdf-files 2/6
9/27/2019 Adobe Acrobat: How to batch to combine multiple pdf files? - Super User

@echo off
setlocal enabledelayedexpansion
:: Concat all paths fromselected files and save it as command
FOR %%A IN (%*) DO (set command=!command! %%A)

:: Take path from first selected file and save it as path


set path=%~dp1
echo %path%

:: Check if a trailing slash is present. If yes, remove it


IF %path:~-1%==\ SET path=%path:~0,-1%

:: Get last folder from path


FOR %%F in ("%path%") do (set lastFolder=%%~nxF)

:: Call pdftk, pass on command. use lastFolder as filename


pdftk.exe %command% cat output "%path%\%lastFolder%.pdf"

edited Aug 23 '18 at 10:50 answered Jan 2 '13 at 13:37


nixda
22k 11 82 140

VERY nice answer. I am struggling to modify it, so it saves as the FOLDERNAME instead of binder.pdf. How
could I do that? – Chen Stats Yu Aug 22 '18 at 23:29

@ChenStatsYu See update – nixda Aug 23 '18 at 10:50

GREAT!! Sorry to ask again, not sure if I should start a new post. Just one last request, as I am repeating this
for nearly 40/50 folders, can we modify it to send the "folder" to the cmd and use the foldername, instead of
selecting some pdfs from the folder? – Chen Stats Yu Aug 23 '18 at 22:33

Also, I am hoping to have it supporting non-English foldernames. – Chen Stats Yu Aug 23 '18 at 22:47

If you're on Linux (or Mac, or any environment where it is installed), you can use a command-line
tool called ghostscript to combine them.

5 gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH file1.pdf


file2.pdf file3.pdf

You can also use the following to combine all files in the current folder

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH *.pdf

You can download ghostscript here. There's a Windows version as well, but I didn't test it.

answered Feb 14 '12 at 13:18


Cacovsky
163 1 7

1 It works on windows, too. I had to write the full path to the ghostscript executable (on my PC it's "c:\Program
File\gs\gs9.07\bin\gswin32c.exe") and the "*.pdf" expansion doesn't work, but ghostscript itself works
perfectly.– Pitarou Feb 22 '13 at 7:05

https://superuser.com/questions/389760/adobe-acrobat-how-to-batch-to-combine-multiple-pdf-files 3/6
9/27/2019 Adobe Acrobat: How to batch to combine multiple pdf files? - Super User

I have used the above solution successfully. However, on my system (Windows 7 64-bit) the code
as it is adds the PDFs in (apparently) random order, not alphabetically by filename.

3 To get it to add files in alphabetic order you will need to add the sort-object parameter to the DIR
(aka Get-ChildItem) command (the sort-object takes no parameter here as filename/alphabetically is
the default):

dir $inputfolder -r -include *.pdf -exclude $outputfile | sort-object | group


DirectoryName % {& $PDFtk $.group CAT OUTPUT "$($.Name)\$outputfile" verbose}

Those who have filenames of the form 1.pdf 2.pdf ... 10.pdf etc. rather than 01.pdf 02.pdf .. 10.pdf
may also like to try a variation of this:

pdftk *?.pdf *??.pdf *???.pdf *????.pdf cat output out.pdf

edited Mar 7 '14 at 10:19 answered Mar 7 '14 at 9:15


karel Giles Hudson
9,986 11 35 41 31 1

"above solution" - presumably you mean nixda's solution. If your answer got voted higher than nixda's it would
be below – noodle Jan 28 '18 at 9:32

There is a new online Advanced PDF Manipulation tool called Sej-da which is still in Beta, which
has a myriad of PDF functions (inc ability to merge multiple pdfs). It free & could well help your
needs.
1
http://sejda.com/

A brief review of its functions was carried out only a couple of weeks ago by Revision 3:

http://revision3.com/tzdaily/sejda-online-pdf

edited Dec 2 '12 at 10:09 answered Dec 2 '12 at 9:45


Simon
3,475 7 33 50

the OP is clearly capable of merging pdf files, he wants to batch merge with an automated process. Your
answer gives no details as to how to use sejda in this way, neither is it apparent from their website –
noodleJan 28 '18 at 9:27

Perhaps it is better to use a batch scenario. Create and collect all your pdf files as xxxx.abcdef.pdf.

First part is the so-called batch tag; second part is file identifier (file name). Tags for each back are
1 similar in length and value; name of files come after the point.

https://superuser.com/questions/389760/adobe-acrobat-how-to-batch-to-combine-multiple-pdf-files 4/6
9/27/2019 Adobe Acrobat: How to batch to combine multiple pdf files? - Super User

For instance your first batch consists of 1111.3425.pdf, 1111.76501.pdf, so on. Your second batch is
22222.1432.pdf, 22222.4398, so on. And so on and so forth for other batches.

Then you can use automated merge software that can deal with thousands of files creating a
separate merge for each batch. I found this Dysprosium free software that does not need a
command line or a batch script. You can download it as a portable JAR file. It has different
automated scenarios; one described in this answer as tagging and one as your required folder
separated.

Depending on your hardware you can batch merge thousands of files into pre-destined batches.

edited Apr 5 '14 at 18:10 answered Mar 24 '14 at 15:44


Any Body
129 5

Try PDFMerge. But don't use the initial form where you have to select each file one by one.
Instead, wait for the site to check your Java installation, then click on "Try the PDFMerge Java
Applet" link. Once the applet is loaded and allowed to run, click on Choose files button, and you'll be
0 able to select multiple files (to merge into one file).

The merging will be superfast and will be able to handle large number of files as nothing is uploaded
into the website. Everything is done in your computer itself using your Java installation.

PS: Sorry if you're looking for an offline software that can be customized to create single PDF files
across multiple folders.

answered Feb 14 '12 at 13:14


ADTC
2,274 3 22 44

If you are on mac you could create an Automator script to achieve this task. Make it as a folder
action and simply drop the pdfs into it and see it happen! If you want I can show you how, are you
running mac?
0
answered Dec 2 '12 at 9:31
Henrik Söderlund
561 4 14

On Linux

0 I wrote this rather long command line

tree -fai . | grep -P ".pdf$" | xargs -L1 -I {} dirname {} | uniq | xargs -L1 -I
{} bash -c 'cd "$0" && pdftk *.pdf cat output binder.pdf' {}

But it does the job, I tested it, it also works with how many levels of folders you have. Just make
sure that you run it a the root of the folder structure.

https://superuser.com/questions/389760/adobe-acrobat-how-to-batch-to-combine-multiple-pdf-files 5/6
9/27/2019 Adobe Acrobat: How to batch to combine multiple pdf files? - Super User

You need pdftk and tree for this and on Ubuntu Linux you can install it with apt:

sudo apt install pdftk tree

answered Feb 8 '18 at 9:15


Eduard Florinescu
1,376 5 21 41

https://superuser.com/questions/389760/adobe-acrobat-how-to-batch-to-combine-multiple-pdf-files 6/6

You might also like