MacOS – Automator action to run python script on series of files fails in Catalina

automatorcatalinafindermacospython

Major edit

I've just discovered that the Automator workflow I'm having problems with works perfectly if I run it by pressing 'play' in the Automator window, and it seemingly only fails when I save it as a Quick Action and try and run it by clicking the button in the Preview pane.

Original post

I have an Automator action that iterates through a list of files selected in the Finder, running a python script on each of them in turn. The workflow receives a list of files or folders in the Finder, and then consists of a single 'Run Shell Script' block with 'Pass input: as arguments'.

for f in "$@"
do
    /path/to/python_distro /path/to/script.py "$f"
done

In Catalina, this fails with an error:
The action “Run Shell Script” encountered an error: “path/to/python_distro: can't open file '/path/to/script.py': [Errno 1] Operation not permitted

How can I get Catalina to permit this? I've already tried adding Automator to the list of apps that are allowed Full Disk Access, and restarted Automator and killall Finder'd, but that did not fix my problem.

Best Answer

In my case adding the Finder to the apps having full disk access in system prefs > security & confidentiality > confidentiality tab enabled me to run a Python script (without this I was also getting an "Operation not permitted" error).