Quick Action returns "no such file or directory error"

I created an Automator Quick Action on my Intel iMac (Sonoma OS) a few weeks ago, which converts a PDF file to version 1.6 from whatever lower version it was previously saved in. (For business reasons, some of my PDFs need to be version 1.6 or later.). On that iMac, it runs fine. I seem to remember installing Homebrew and Ghostscript before I created the Quick Action.

I’ve been trying all night to get that same Quick Action to work on my M2 MacBook Air (also Sonoma 14.4.1, and also with Homebrew and Ghostscript installed), but I keep getting the following error while trying to execute the Quick Action.

The action “Run Shell Script” encountered an error: “zsh:3: no such file or directory: /usr/local/bin/gs”

The Automator script I am using looks like this:

   Shell:   /bin/zch
   for f in "$@"
   do
   /usr/local/bin/gs -q -sDEVICE=pdfwrite -dCompatibilityLevel=1.6 -o "$f"_conv.pdf "$f"
   done

I’ve been banging my head on my desk trying to figure out how to fix the error and get the Quick Action to work on the M2 MacBook Air. I’m sure I’ve probably forgotten one step along the way that’s hanging me up, but I’d appreciate any help on this one.

–Gary

Just in case: is /usr/local/bin/gs actually there?

That directory is there on my Intel iMac (and the Quick Action works) and must have been created during the ghostscript installation. But on my M2 MacBook Air, there’s no such directory, even though I installed ghostscript the same way: I first installed homebrew, then installed ghostscript using “brew install ghostscript” command. I tried installing ghostscript again, and received a query as to whether I wanted to reinstall ghostscript. I did, and the installation appeared to go fine. But still no directory. Ugh.

I’m sure those experienced in homebrew will chime in but it’s possible that homebrew installs stuff someplace else.

Btw you can install Ghostscript using a standard Mac installer here:

https://pages.uoregon.edu/koch/

1 Like

P.S. Try to just run gs in Terminal - will it do anything (or return ‘command not found’)?

If gs is found then you can run which gs to see its location.

I’ve included below a Shortcuts app solution that works by way of a Quick Action. It creates the converted PDFs in the same folder as the source PDFs. After installing the shortcut, the user may need to put a check mark before Finder under Use as Quick Action (see screenshot). I tested this shortcut with numerous PDFs on my Sonoma computer, and it worked as expected.

PDF Convert.shortcut (22.4 KB)