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:
for f in "$@"
do
xattr -rd com.apple.quarantine "$f"
done
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.
- Note: Upon manually placing file(s)/folder(s) into the target watched folder and authenticating that action, I was then prompted to re-enter my credentials so the
do shell script
command would run as if using sudo
on the command line in Terminal on the xattr
command
.
Example AppleScript code:
on run {input}
set itemList to {}
repeat with aItem in input
set end of itemList to quoted form of (POSIX path of aItem) & space
end repeat
set shellCMD to "xattr -rd com.apple.quarantine " & itemList as string
do shell script shellCMD with administrator privileges
end run