Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?!

share|improve this question
    
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

9 Answers 9

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 merge@pdf.cmd in the same folder as pdftk.exe and libiconv2.dll enter image description here
  • 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

    enter image description here

share|improve this answer

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.

share|improve this answer
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

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.

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
share|improve this answer

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 similar in length and value; name of files come after the point.

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.

share|improve this answer

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 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.

share|improve this answer

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?

share|improve this answer

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.

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

share|improve this answer

CoolUtils has a product called PDF Combine which will take command line parameters and do exactly what you described above. It's very fast and cheap.

CCS 2/10/2013

share|improve this answer

This PowerShell script searches all subfolders and catenates all PDFs per folder to a single PDF

Preparation

  1. Download & extract pdftk with UniExtract. It's a powerful commandline tool for processing PDFs
  2. Open {APP}\pdftk\bin and copy pdftk.exe and libiconv2.dll to a folder of your choice.
  3. Create a new text file, paste the following code and save it as .ps1 file
  4. Change the 3 input variables if needed

$PDFtk = "C:\pdktk\pdftk.exe"
$inputfolder = "C:\rootfolder"
$outputfile = "combined_file.pdf"

dir $inputfolder -r -include *.pdf -exclude $outputfile | group DirectoryName |  
% {& $PDFtk $_.group CAT OUTPUT "$($_.Name)\$outputfile"}

Logic behind

  • Get all files from all subfolders, starting at given path
    • include only PDF files
    • but exclude existing outputfiles from previous runs
  • group PDF files per folder
  • start PDFtk.exe once per folder and pass these parameters
    input1 input2 [...] inputX CAT OUTPUT foldername\combined_file.pdf
    • if outputfile already exists, overwrite it

PDFtk help sites

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.