Script for converting whole folder (img, pdf, text) to one PDF


I am looking for a solution (Script or Automator) to convert everything within a certain folder to one PDF file. Does someone know with which tool I could accomplish that? The standard PDF automator possibilities do not work… pictures-to-pdf. And I tried to use Abby Fine Reader, but the automator works just for single files, and I cannot find a possibility to combine them.
Does PDFpenPro has this possibility? Or Adobe Acrobat? Or is there a shell-script program I could use?
… I am stuck… :frowning: Thank you in advance!



Rather than thinking about this as one problem, have you tried breaking it down?

For example, I would imagine an approach like this could work.

  • Find something to convert one image to a PDF.
    • e.g. ImageMagick
  • Find something to convert one text file to a PDF.
    • e.g. Pandoc
  • Find something to trigger an automation against a file.
    • e.g. a shell script checking the file extension and then running a command line instruction.
  • Find something that can trigger against multiple files.
    • e.g. a shell script can loop over multiple files.
  • Find something to combine multiple PDF files into one.
    • e.g. qpdf
1 Like


So an update :slight_smile: Thank you sylumer – that is now exactly what I am doing!
Converting the files to PDFs is no problem with automator and calibre. When all documents are pdfs I merge them with qPDF! Thanks for the hint! Vidman2019 helped me on, here, with the script.
In Hazel I use the shell script:

for f in $1; do qpdf --empty "${f%.pdf}-joined.pdf" --pages "${f%.pdf}"*.pdf --; done

That works if the files are named original-file.pdf, original-file-1.pdf. original-file-2.pdf etc. where original-file is any filename.

1 Like