OSX comes with a bunch of nice utilities in /System/Library/Automator
. I’d like to use the command line to invoke them.
For example, I’d like to split each page of a PDF into individual pdfs. The Split PDF.action
seems to do that, but I don’t know how to invoke it from the command line. I’d like to know:
- How do I invoke the action?
- How do I see which arguments it take, e.g., something like a
man
page?
What I’ve tried
I’ve tried calling the binary file in MacOs folder, but that seems to not be an executable and fails with zsh: exec format error
. Example:
% ls -l "/System/Library/Automator/Split PDF.action/Contents/MacOS/"*
-rwxr-xr-x 1 root wheel 135824 May 7 2024 /System/Library/Automator/Split PDF.action/Contents/MacOS/Split PDF
% "/System/Library/Automator/Split PDF.action/Contents/MacOS/Split PDF"
zsh: exec format error: /System/Library/Automator/Split PDF.action/Contents/MacOS/Split PDF
I’ve tried naively passing the path of one of these actions to the automator command either that’s not supported, or I need to use a different format:
% automator "/System/Library/Automator/Split PDF.action/Contents/MacOS/Split PDF"
The document “Split PDF” could not be opened because it is damaged or incomplete.
% automator "/System/Library/Automator/Split PDF.action"
The document “Split PDF.action” could not be opened because it is damaged or incomplete.
% automator "Split PDF.action"
The file “Split PDF.action” couldn’t be opened because there is no such file.
The operation couldn’t be completed. No such file or directory
Exceptions: A few actions have an executable in their MacOS folder, in addition to the “action” binary.
Looking through the files, I’ve found these actions with an executable
/System/Library/Automator/Extract Odd & Even Pages.action/Contents/MacOS/extract
/System/Library/Automator/Build Xcode Project.action/Contents/MacOS/uid
/System/Library/Automator/Add Grid to PDF Documents.action/Contents/MacOS/graphpaper
/System/Library/Automator/Combine PDF Pages.action/Contents/MacOS/join
For context https://apple.stackexchange.com/a/230447/74037 covers the last one.
Alternatives for Splitting PDF
Splitting PDFs is just an example. I’d like this question to be focused on running any automator action, not alternatives for splitting PDFs. For that particular need plenty of alternatives are already documented (see e.g. https://superuser.com/q/827462).