macOS Catalina causing "find: .: Operation not permitted" errors

by The Shockwave   Last Updated October 10, 2019 02:12 AM - source

I have an automation workflow that I use as a Quick Action. It takes a Finder item and calls a shell script with it. Part of the shell script runs a find command on the directory of the Finder item. Prior to Catalina, this worked. Now I get

find: <path to the directory>: Operation not permitted

This only happens when I'm running it as the Service Quick Action. If I call the script in Terminal, it works fine, as does the find command in Terminal.

# Directory to delete files from
REAL_FILE=$(/usr/local/bin/realpath "$1")
DIR=$(dirname "$REAL_FILE")

find "$DIR" -type f -depth 1 -print0 | while read -d $'\0' FILE
    if [[ "$FILE" < "$REAL_FILE" ]] ; then
        mv "$FILE" ~/.Trash/

Related Questions