Using Automator CLI with passed file name

automatorpdf

I'd like to apply a quartz filter (Reduce File Size) through Preview Export using the command line while passing in the input and output filenames through CLI. I'm thinking the best way to do this is through Automator since it seems there isn't a way to access Preview through CLI.

I'm thinking it would look something like this in the end:

automator -i input=input.pdf output=output.pdf PDF.workflow

But I'm probably completely off.

Here's the basic workflow, which doesn't work as hoped:

workflow

Best Answer

MacOS (OSX) used to have a Terminal command quartzfilter, which would apply a Quartz Filter to PDFs and allow output names. Sadly, it was removed in Snow Leopard.

Here's a python script which works as a replacement.

The Automator action "Apply Quartz Filter to PDF Documents" applies the filter to the input, so your workflow copies the PDFs but then over-writes the originals with the Filter.