I have a line of code (that I can run successfully in Terminal) I'd like to incorporate into an Automator workflow but I can't work out how to reference the filename. I've set up my workflow as a Folder Action and applied it to the correct folder so dragging a new file to that folder triggers the workflow (this part is working correctly).
My line of code is
sudo xattr -rd com.apple.quarantine [PATHNAME_TO_FILE]
It sets the preferences on the file to obviate Apple's quarantine process run by the Logic program, allowing a third-party file to pass muster.
What does Automator want me to use as [PATHNAME_TO_FILE]? I've tried "$@", "$#", "$0", "$1", "$2", etc, etc. but had no luck.
Best Answer
If you've set up an Automator workflow as a Folder Action and have added a Run Shell Script action, you'd set Shell: [/bin/bash] and Pass input: [as arguments] and use the following example shell script code:
Note: You should not need to use
sudo
as you've shown in your OP.Update to address comment:
If the target of the watched folder is
/Library/Audio/Plug-Ins/Components
, as in the root of the Macintosh HD, then you'll need to take a different approach.Set up an Automator workflow as a Folder Action adding a Run AppleScript action, replacing the default code with the example AppleScript code shown below.
Testing under macOS Catalina 10.15.6 the Automator workflow Folder Action, described immediately above, worked for me when adding file(s)/folder(s) to
/Library/Audio/Plug-Ins/Components
, as in the root of the Macintosh HD.do shell script
command would run as if usingsudo
on the command line in Terminal on thexattr
command .Example AppleScript code: