Is it possible to pass an Automator variable into a shell script?
To complement @Ned Deily's answer:
(Written as of OS X 10.9.2, still current as of OSX 10.10)
It is often not necessary to create and use explicit variables in Automator (using the Set Value of Variable
and Get Value of Variable
actions).
The previous action's output is automatically passed to a Run Shell Script
action.
By default, the data is passed via stdin, however.
If you want it passed as arguments ($1
, $2
, ... - also accessible as an array via $@
) instead, select as arguments
from the Pass input:
list on the right, as illustrated here:
In this example, the selected Finder
items are passed as POSIX-style paths to the shell script.
That said, having a shell script process the data via stdin (using read -r
in a loop) works, too:
filename
variablefilename
variablerename_to
rename_to
value, $2 – filename
valueIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With