There’s quite a bit to unpack right here:
Firstly, Automator has an Apply Quartz Filter motion, which is so much simpler to person than AppleScript. (Quartz Filters are an OS function, not simply Preview’s.)
Secondly, the OS-bundled filter to Scale back file measurement is well-known for being horrible, and you’ll find varied third-party filters that present higher settings. Or you possibly can create your individual filter in ColorSync Utility, as per my reply right here.
Thirdly, Apple made numerous adjustments to PDFKit in Sierra, and with that got here many bugs in PDF creation and manipulation. Most of those have been fastened in Excessive Sierra, however some lingered till Mojave. Any Mac working Sierra needs to be able to working Excessive Sierra, not less than.
If there is a compelling purpose why you have to keep on Sierra, then I would recommend downloading a appropriate model of GhostScript, which ought to be capable to batch-compress PDFs very simply.
Additionally, it seems to be such as you’re utilizing a Visitor person account? (Except that is your identify.) It is potential {that a} visitor account has restricted permissions, which could trigger issues.
As for the AppleScript itself, it seems to be like there isn’t any such command as export
within the Preview AS dictionary. (There is not in Sonoma, not less than: however it is best to verify the dictionary in Sierra.)
One ultimate factor about your shell script: The ‘bizarre characters’ within the Terminal output have been truly the information contents of the PDF file being written to stdout
. The -o
flag passes choices to the print driver; it would not set the output file. Additionally -p
units the PPD for use. You possibly can’t apply a Quartz Filter to cupsfilter. (CUPS has its personal ‘filters’, that are a totally completely different factor.)
One thing which may be helpful is that this python script, which you need to use on the command line to use quartz filters to PDFs. It makes use of the system python2, so that you need not set up something.
https://github.com/benwiggy/PDFsuite/blob/grasp/legacypercent20(pythonpercent202)/Shell_Scripts/quartzfilter.py