Render PDF files to JPG but only a certain number of pages / first page

I followed this article and it worked perfectly. Automator - Render multiple PDF as JPG an… - Apple Community (comment from VikingOSX April 13, 2019 11:16am)


However, I only want the first and second page of each file to render, not every single page.


I modified the shell script by adding "PAGEMAX-2" before the script but it didn't work.


OUTDIR="$HOME/Desktop/JPEG/"


for f in "$@"

do

# a by product of the render is generation (nn) sets (e.g. foo nn_01.jpeg) and Ruby removes to make (foo_01.jpeg)

OUTFILE="$(ruby -e 'puts File.basename(ARGV.first).split(/(?<=\s)\d+(?=_)/).map(&:strip).join;' "$f")"

mv "$f" "$OUTDIR$OUTFILE"

done


MacBook Air 13″, macOS 10.15

Posted on Apr 10, 2024 3:02 PM

Reply
1 reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Render PDF files to JPG but only a certain number of pages / first page

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.