I am trying to automate some accounting tasks. For this purpose I have employed Noodlesoft Hazel's help to rename and sort documents. However, I am stuck at trying to combine PDFs that really belong together (i.e. invoice from vendor with receipt from payment portal for the same purchase).

More specifically, the names of the documents to be combined have the same first part, say:

2017-02-01 Vendor1 - invoice1234.pdf
2017-02-01 Vendor1 [PayPal] - transactionID.pdf

Is there a way to combine them automatically (i.e. running a shell script in Hazel), possibly using pdfunite? It would be important to retain the name of the second file, but combine the two into one PDF.

I have some basic scripting knowledge and would be up for the challenge!

  • Something like a Table of contents page that links to the 2[++] pdfs with the original file names in the TOC? might be possible with LaTeX package pdfpages. Commented Feb 8, 2017 at 16:29
  • So, all files are in one folder and all files that begin with Vendor# should be combined? Or all Vendor# files are already separated into subfolders? Commented Feb 8, 2017 at 17:20
  • I collect all files in one folder. The date (and thus the file name) is really what gives away which ones belong together. I was thinking an if-statement would determine wether the first portion of 2 files is the same, and if so, run a command to combine and rename them (and discarding the two individual files aftwards).
    – tobiasnyc
    Commented Feb 11, 2017 at 10:54

1 Answer 1


A linked question How can I combine PDF files and automatically create a table of contents? offers a program to do this. I don't know the syntax for scripting it with hazel/applescript/automator/ruby what have you though.

  • Thank you - I'm not really looking for a table-of-contents solution. I just need to be able to automate the process with a script. I have worked with some of the programs mentioned in that thread. I think a solution using pdfunite or pdftk would be more along the lines of what I'm trying to accomplish.
    – tobiasnyc
    Commented Feb 11, 2017 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .