Converting all images in a specific folder to PDFs

Hi there I am new to the forum and found some awesome examples already. Certainly the script that my question revolves around to. I am trying to convert all images in a folder to a pdf. The script I found only works when the folder selected but I want to specify the folder (to be replaced by a variable later because this be work on multiple folders in the end). I always get the error like this one Capto_Capture 2020-06-17_01-42-39_AM
Here is a screenshot of my attempt so far

I am grateful for any suggestions here is my script so farConvert folder of jpgs to pdf.kmmacros (6.0 KB)

This works for me:

Convert folder of jpgs to pdf.kmmacros (4.8 KB)

Doesn't work for me. I don't get any errors but also no results. If I change the folder in the beginning the tester (one level above) I get one PDF of one image. That's it. Is it possible that the Script works differently in Catalina, I'm still working on Mojave. Thanks for the quick response.

Not using KM, but still solves your problem. I prefer using covert .
so a shell script would be

for file in ls $FOLDER/*.jpg
convert $file $file.pdf

Did you try my macro, or modify the one you were originally using? Your original macro failed to include the convert script action inside the For Each loop that iterates over files, so it also only converted one file for me until I fixed that.

Hi I downloaded your version which seems to be identical to the screenshot you posted here. Am I missing something?

@baramuro's macro works with one fix and one remaining weird behavior.

The fix:
The last action lacks a slash "/" (see highlighted below):

Once the slash "/" is added, the macro will work.

The weird behavior:
Working on 800+ images in a folder, the macro randomly renames 20+ pages from the images and then convert all images into a single PDF file. The result is that these 20+ pages are out of sequence. I have to reorder the pages.
I don't understand why the renaming actions are included in the macro. (Edit: removing the renaming actions seems to work well.)

@gglick, your macro works, but it converts each image into an individual PDF, not all images into a single PDF.

It looks like they want to build the PDF with the images in creation date order, rather than the default file-names-in-ASCII-sort order. That's what's causing all the extra steps -- if you just want to order by file name then you don't need to do much more than grab the path to the parent folder and use that in the Shell Script action.

Thanks for the info. I don't understand the shell script, I think I just copied it from a source in the forums that tried something similar. I never got it to work, probably because of the missing slash. If I remember correctly my goal was to convert a bunch of folders with 4-7 images into one pdf so I could mark them. Greatly appreciated feed back thanks

I guess I am too stupid for this but the script doesn't work for me. I get an error message like this

Note that convert isn't a stock macOS Unix tool, it's part of, which is a huge, powerful, and complex command line tool for manipulating images in all sorts of ways. You won't be able to use the macro that references that script unless you install ImageMagick. And doing so can be complicated, depending on your level of comfort in Terminal—the easiest way is through Homebrew or MacPorts.


Thanks for the info, I think I'll pass since that a project during covid with all my students sending me images instead of pdfs

If this comes up again -- remember that you can do this directly in the Finder!

Select all the images you want in the PDF, then right-click one and "Quick Actions..." then "Create PDF":

Files will be added in the same order as your Finder window sort -- in the above case, by date with newest first -- and the file will be named for the first image in the selection.

1 Like