Adobe Acrobat: How to batch to combine multiple pdf files?
I have 3 folders:
Folder 1
Folder 2
Folder 3
In each folder I have 5 pdf files:
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?!
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.
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 [email protected] 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
@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"
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.
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.