How to Automate Saving the First Page of a Batch of PDFs as JPGs

Not specifically a FileMaker challenge today, this is an Apple Macintosh Automator/Shell Script routine. I recently had the requirement of generating a set of images for a large set of PDFs—I just needed the first page of a batch of PDFs converted into JPG files. Fortunately, as usual, some smart person has already done this (or something very much like it) and made a ‘how-to’ on the Internet. A bit of searching and I came up with this method from Stackoverflow, combined with some information from MacScripter.


This Automator routine does the following:

  1. When run, this prompts the user to select a file, a folder or a selection of files (Shift Select). Set up the Automator step with these options:

Starts at: in my case, I was starting at the Desktop, but it could be any selected folder.

Type: Files and Folders, so that the user can select either

Option: Allow Multiple Selection: TRUE

  1. Gets the Folder Contents (this allows you to target a top level folder with sub-folders. In the Automator step set this option:

Option: Repeat for each subfolder found: TRUE

  1. Runs a Shell Script which uses the SIPS command. Basically this is feeding a loop of files into the SIPS Shell Script and converting from .pdf to .jpg. That process, since jpgs are single page documents, creates a file from the first page of the pdf file. In the Automator step be sure to set these options:

Shell: /bin/bash

Pass input: as arguments

This is the Shell Script:

for f in "$@"
 sips -s format jpeg -s formatOptions 100 "$f" --out "${f%.pdf}.jpg";
 echo "${f%.pdf}.jpg"

I didn’t find that the formatOptions had the impact of setting a lower DPI setting, my jpg files were the same 150 dpi as existed in the PDF. There may be more to it. If not, Automator is pretty good at resizing files, so you could add that to the workflow if required.


Here is the final result of my JPEG assembly: The Computer Paper Covers

Comments are closed.

%d bloggers like this: