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

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

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
do
    if [[ "$FILE" < "$REAL_FILE" ]] ; then
        mv "$FILE" ~/.Trash/
    fi
done


Related Questions


Updated April 20, 2015 01:05 AM

Updated August 10, 2018 10:12 AM

Updated March 29, 2015 09:04 AM

Updated February 02, 2018 15:12 PM

Updated April 20, 2019 08:12 AM