How To Combine PDF Files in Mac OS X Using Automator To Make A Service

Many scanners let you choose between scanning one-PDF-per-page or scanning all the pages into one big PDF. The scanner I use does.

However, what happens when you have multiple PDFs that really should go in one document? How do you combine PDFs together?

There are a million ways to do this, including some I have talked about before like using Preview.app to drag and drop pages, and there are lots of applications that one can use to combine PDFs, but I wanted to do something that would be:

Already built into the OS and not require any additional software.

Easy to use.

Repeatable so I only have to set it up once and can use it again and again.

We’re going to use a Mac OS X tool called Automator to set this up. If you have seen my How to Split PDFs tutorial, this is basically the reverse.

Start Automator

In Finder, go to Applications and then start Automator.

Choose Service

In the window that pops up, highlight Service and then hit Choose.

Automator Choose Service

Set The Variable For The Original PDFs

At the top of the window at the right, change the Service receives selected dropdown to PDF files. I set the in dropdown to Finder.app. I haven’t tested it in other applications.

Now in the Library section on the left, click on Utilities and then find Set Value of Variable. Drag it to the main window on the right.

In the Variable dropdown, choose New variable… and call it originalPDFs.

Here’s what the first rule looks like so far.

Set The Variable For The Path Of The PDF

We are doing this step because of a weird way Automator works. It doesn’t make it easy to save the resulting PDF to the same folder as the original.

I could prompt the user to choose a path, but I wanted to make it automatic so we have to get a bit geeky.

Note: if you’re an Automator expert and know a better way to do this, please leave a comment!

Still in the Utilities section of the Library on the left, find Run AppleScript. Drag it to the main window under our last step.

In the Run AppleScript window, paste in this code:

on run {input, parameters}
set pathList to {}
repeat with itemNum from 1 to count of input
tell application "System Events"
copy POSIX path of (container of (item itemNum of input)) to end of pathList
end tell
end repeat
return pathList
end run

(Basically that is going through the PDFs that you are splitting and copying the folders that they are stored in.)

Now in the Utilities section of the Library, find our old friend Set Value of Variable and (you guessed it) drag it into the main window under our last step.

In the Variable dropdown, choose New Variable… and give your new variable a name of containerPath.

Here’s what these steps look like:

Combine The PDFs

Now it’s time to do the combining!

First, we want to get the list of PDFs that we had saved back in the first step.

In Library -> Utilities, drag Get Value of Variable to the main window under our last step.

In the Variable dropdown, choose originalPDFs.

Right under the Variable dropdown there is an Options button. Hit that and check Ignore this action’s input.

Now in Library on the right, choose PDFs. Find Combine PDF Pages and drag it under the last step.

Next, in Library on the right, choose Files & Folders. Find Rename Finder Items and drag it under the last step. It will pop up a message asking you if you want to preserve an extra copy. We don’t need that, so hit Don’t Add.

In the Rename Finder Items box, change the dropdown to Name Single Item. Then hit the Options button and check Show this action when the workflow runs. This will let name the new PDF.

Next, also in Files & Folders, drag Move Finder Items under the last step. In the Variable window at the bottom of your screen, find your containerPath variable. Drag it up on top of the To dropdown.

Here is what those last steps look like:

Combine PDFs

Save The Service

Alright! You’re done! Here’s the entire rule (click to see it bigger):

Use The Combine PDFs Service

You have just created a Service. This means that if you right-click a group of PDFs in the Finder, you can combine them right from there. Let’s try it.

Find a group of PDFs on your Mac, highlight them, and right-click. Choose the Services menu near the bottom. If all went well, you should see Combine PDFs (or whatever you called your Service) in the list. Choose it.

Combine Mac Service Right-Click

It will think for a moment and then pop up a box where you can give the new PDF a name. I just called mine “Combined”.

Combine Mac PDF Give Name

Boom. I now have a PDF called Combined.pdf that contains all the selected PDFs.

Mac PDF Combined

Best of all, since I went through this trouble to set it up as a Service, going forward whenever I need to combine PDFs, I just have to right-click on them.

Downloading The Service

If you don’t want to go through the hassle of setting this all up, you are welcome to use mine.

To use it, download the file to your computer and double-click it to Unzip it.

You want to move the file to the ~/Library/Services folder. It’s probably hidden for you, so the easiest way to get there is:

About the Author

Brooks Duncan helps individuals and small businesses go paperless. He's been an accountant, a software developer, a manager in a very large corporation, and has run DocumentSnap since 2008. You can find Brooks on Twitter at @documentsnap or @brooksduncan. Thanks for stopping by.

Leave a Reply:

Thanks so much for this great post!
One question – how do I put this into a loop, i.e. tell the automator function to go through one folder after the other? so that at the beginning of the whole procedure, instead of choosing the pdf files to combine, I choose the folders in which the automator should combine (all) the individual pdfs and save the result in the respective folder?

Leave a Reply:

Leave a Reply:

I tried to create a service following your instructions myself, but it didn’t work. I downloaded your zip file and it works fine. Didn’t know where I did wrong lol.

In the past I have been using “Combine PDF pages” from Library directly, but I was frustrated that it doesn’t append pages by name. For example, when I rename all my PDF pages I want to combine from 1 to 100, which is the order I intend, automator doesn’t combine from 1 to 100. Instead it combines in such an order as 1, 11, 12…2, 21…. It is the same if I rename my files 001, 002, …100. I don’t understand its logic and don’t know how to circumvent this seemingly simple problem. Am I missing some easy steps?

Thanks a lot!

Leave a Reply:

Hi, I was just looking for a easy way to combine pdf files on mac without additional software or using preview. Thank you very, VERY much for this tutorial, you just saved me many cumulative hours of work 🙂

Leave a Reply:

This has been working great. I have a question: If I have documents that have an odd number of pages and I want to make them all even before combining them. Is there a way for me to have the program identify the files that have odd number of pages and have them add a page at the end automatically, then proceed to combine the pdf? or will I need to do this manually?

Leave a Reply:

Leave a Reply:

Amazing! Just wanted to tell you how helpful this, along with your post on splitting PDFs was to me! Both worked like a charm on my MacBook Pro running Yosemite 10.10.5. Happy New Year and thank you so much for sharing this. -Tanya

Leave a Reply:

Tried this and something didn’t quite work. I had used Automator in the past to combine pdfs and thought it had been easier. Still, I like the idea of a “Pre-set” option. Turned out the next site I found helped me create just that and it was much simpler. Here is the link to those instructions. https://paulminors.com/merge-pdfs-mac-automator/
Some steps are similar and I was glad I had already gone through these steps as they made it easier to locate certain actions required. Anyway, thanks for your tutorial.

Leave a Reply:

Leave a Reply:

I downloaded this to combine pdf cover page’s to separate pdf document’s. The first couple times it worked perfectly.

Now, it keeps putting the cover page at the end of the document rather than the beginning. I’m selecting the document’s in order using the command key, just in case that was the issue, but nothing seems to change the outcome.

Has anyone else experienced this issue, or does anyone have any insight that may help?

Leave a Reply:

This is great! My attempt at building the script didn’t work, so I am glad you have it available as a Zip file.

Because I have found combining things in Preview to be frustrating, and whenever I scan something, any time I have to stop results in multiple documents. Consequently this is exactly what I was looking for.

Leave a Reply:

Leave a Reply:

I ended up downloading your zip file, weirdly, the service “combine pdf” only appears when i select only one pdf. When I select two, I don’t have the choice to combine them. Any clue why? on the latest 10.11.3

Thanks a lot

Leave a Reply:

Holy cow that’s easy!
I’d been using Acrobat Pro’s combine pdf functions but I needed to
(1) open Acrobat Pro
(2) select “Create” from the File menu and select “Combine files into a single PDF”
(3) drag the files into a popup box (or select “Add files” and then choose the files )
(4) select “Combine files”
(5) select “Save” from the File menu
(6) name the new file
With the script I just need to
(1) select files
(2) right click, select “Services,” and then select “Combine PDFs”
(3) name new file
Much faster and more efficient! Thanks!
Tom

Leave a Reply:

You may have figured this out already but if you open any one of the PDF pages you want to combine and then change the view to show the Thumbnails (Opt+Cmd+2) on the side, you can drag pages into the thumbnail frame that way.

The PDF files you drag in don’t have to be open, but you can do it that way as well. Hope that helps.

Rob

Leave a Reply:

Brilliant! My sincerest thanks, Brooks, for saving me from hours of former frustration with a ‘sometimes-effective-combining-function” in Preview. Yours has been one of the most practical and helpful blogs I’ve perused since acquiring a Macbook.

Leave a Reply:

Combining the PDF’s with Automator is fantastic! Is there a way to do this combining .csv files created thru ScanReceipt? I’ve been trying to come up with an easier way to merg the .csv files I’ve created. I’m not comfortable scanning all my receipts into Scan Receipt and leaving them there until I’m ready to do my taxes. Thanks for any help you can give!

Leave a Reply:

[…] You can buy software to do this, but there are options to split a PDF using the built-in tools of Mac OS X. You can think of this as a companion piece to How To Combine PDFs Using Mac OS X Automator. […]

Leave a Reply:

Leave a Reply:

Hi! Great idea! I am doing this right now! The problem I seem to have run into, is that it only works up to 1000 items. I am trying to merge a 1166 page book, that was scanned one page per pdf. Any ideas to increase the 1000 file merge limit? Thanks in advance!

Leave a Reply:

This is possibly the most helpful thing I’ve seen all week. SO MUCH TIME SAVED, YET SO EASY. I also had no idea about the Automator tool at all, so this was a really cool introduction to it. Thanks so much for this tutorial!

Leave a Reply:

One of the things I have been really missing since leaving Windows was a set of utilities called PDFill FREE PDF Tools, which I used mainly to merge PDFs. I knew you can do this using Preview, but, let’s face it, that’s kind of a pain. I teach, so I have to combine PDFs all the time. This was a great tip, and more importantly, I have learned a world of possible actions I can create using the amazing Automator, which I have used before, but I am much more familiar with now through your tutorial.

Leave a Reply:

Hey thanks this was a great solution.
Just a quick one (Didn’t seem to see this in thread…)

I am interleaving Simplex scanned pages with a second set of pages odds then evens.

To get correct interleaved of odd then even pages – I found that when I select the two original files the odd number file (I.e. the first page, third page 5th pages to-be) had to be the top file when selecting the two files in the finder. (This is when running the automator script)

I.e. just the top file as the files are displayed in the finer window. Even just reversing the alphabetical display of the files in as they are listed in the finder works if you happen to have named the one you want as the 1,3,5 pages with a alphabetical character later than the 2,4,6 file (Like Odd Filename : Even Filename)

Leave a Reply:

[…] Console Download 4 ….. active, loop-free data path between all nodes in the network. How To Combine PDF Files in Mac OSX Using Automator To Make … Aug 10, 2010 … How about a free 7 part e-Course to help turn your stacks of paper into an […]

Leave a Reply:

[…] How To Combine PDF Files in Mac OSX Using Automator To Make … Aug 10, 2010 … A close friend of mine is currently doing a year long round-the-world trip. Being the sucker nice guy that I am, I have agreed to receive her mail … […]

Leave a Reply:

Leave a Reply:

Hey brooks great post! I'm trying to create a very similar automator script using the Folder Actions option, so that every time I add a new PDF (1page) to a certain folder it automatically combines with a certain PDF (2 page) doc, to make a 3 page PDF which I can then rename etc as above. The issue I'm having is it puts my 1 page doc in the middle of the other 2 pages, so its out of order. Any tips on setting this right?

Leave a Reply:

Leave a Reply:

Embiggen is a perfectly cromulent word, and this is a superbly cromulent tutorial! Thanks for helping me try Automator, it's kinda cool. And my PDF files go into my new document in the correct order! All I had to do is sort by Date Modified! Oh happy day!

Leave a Reply:

Thanks for the link to my blog post about combining PDF documents. I must admit, at the time of writing it, I hadn't sorted out all the little issues with my workflow, so I can see how it may be confusing to read through and "play at home" so to speak for those who aren't confident with using Automator.

I'm glad my post inspired you, and it's great that you have taken the initiative to make things a little clearer.

DocumentSnap was created by Brooks Duncan (that's me). I started it in 2008 as I was going through my paperless journey. Now I share what works (and what doesn't) so you know exactly how to go paperless yourself.