• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Batch merge PDF files

Page history last edited by Monica 9 years ago

Purpose

To combine multiple PDF files into one PDF file. Best used when files are stored across many subfolders and wish to create a single PDF per subfolder.

 

Software

Poppler/pdfunite

Exiftool

Excel

Mac command line/Terminal

TextEdit

 

Note: Poppler/pdfunite is install on the MovingImages Mac Workstation (DMCAdmin access only)

 

Basic Command

pdfunite utility is part of the poppler-utils package. Pdfunite merges several PDF files, in order of their occurrence on the command line, to one PDF output file.

 

pdfunite input1.pdf input2.pdf input3.pdf output.pdf

 

pdfunite *.pdfoutput.pdf

  • remember to provide output.pdf, or else it will overwrite the last file in your command

  • May use the wildcard (*) assuming no other PDFs exists in that directory and native order is desired, otherwise list individual filenames in the order wish to be combined.

 

 

STEPS

The following are suggested methods for creating a batch process for combining PDFs.

A. Identify files and folder organization

 

Answer the following questions:

  • What is the total number of subfolders containing multiple PDFs to be combined? This number will be a control check for output PDF files at end of process.

  • What are the full directory paths for each subfolder? Each path will be used to prepare command lines in the next step

  • Do any subfolders contain only a single PDF? These will need to be processed manually as pdfunite needs more than one file to combine. Simply copy PDF and rename.

 

Method

 

  1. Run exiftool –csv command for top level folder

exiftool –csv –r topfolder>exifdata.csv

  1. Open exifdata in excel

  2. Create pivot table to summarize total PDF files per subfolder. This info will be used to create directory paths in next step

 

Example Pivot Table Results

 

B. Create commands per folder

  1. Use the list of subfolders generated by pivot table (only include folders with greater than 1 PDF file) to create directory path

  2. Insert command pdfunite for all rows

  3. Insert new filename for the combined PDF

    1. TIP: new filename may be created from subfolder name using =CONCATENATE formula

 

Example: Create New Filename for Combined PDF

 

 

Example: Create rows of commands per folder

Where cell H1 is the main path for all subfolders and B? is the subfolder name.

 

C. Shell Script

Use Bash (or Shell) scripting to run multiple commands from one executable file

 

Create the Script

  1. Open TextEdit

  2. Put the editor into Plain Text mode by selecting Format > Make Plain Text.

  3. On first line enter: #!/bin/sh

  4. Copy commands lines created in above step

  5. To save the file, click File > Save As in TextEdit. Enter your filename followed by the “.sh” file extension, and then Save the document.

  • TIP: Save the file to a new folder where all the merged PDFs will be output.

 

Short cut for Save and exit: CTRL-O <ENTER>, CTRL-X <ENTER>

 

In the Finder you can also put ".command" at the end of "your file". If you do that, your script will open the Terminal and run it.

 

Example Script

Set the Permissions

Before you can run the script in the terminal, you must set the permissions on the file so that the file can be used as an executable. To do this, open the terminal, and navigate to the location where the file is saved. Then, type in the following command to change the file permissions:

 

chmod 755 createPDFs.sh

Run Script

To run your script, navigate to its saved location, and type in the following command:

 

./createPDFs.sh

 

Other References:

Combining PDFs testing results (from Thresher student newspaper project, 2011)

 

 

Comments (0)

You don't have permission to comment on this page.