Running shell script with ImageMagick on files

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Hi all!

I'm trying to run a shell script on images dropped into a particular directory to strip EXIF data:
Code: Select all
# Get the ICC profile for the image
magick $1 $1.icm
# Strip the original image, adding back the ICC profile
# to a new file
magick $1 -strip -profile $1.icm $1_stripped

# Remove the original file and rename the new file
mv -f "$1_stripped" "$1"
# and remove the icc profile file
rm $1.icm

I'm trying to use the "embedded script" feature, but it doesn't seem to work; when I try to preview the rule all that shows up in the "Rule Status" window is "Error processing shell script on file xxxx.jpeg". The commands work when run from a shell script file, but when I try to have Hazel run the script file it doesn't return an error, but the image still has its EXIF data.
To make sure the script was being run, I added
Code: Select all
echo "yay" >> zzz.txt
and the zzz.txt file is being created with "yay" in it, so I don't understand what's going on, everything should work, it just ... doesn't. :|

Thanks for any assistance!

Ron
tachoknight
 
Posts: 2
Joined: Thu Aug 21, 2025 5:11 pm

Do not assume any environment variables are set. That includes PATH so specify full paths or setup PATH yourself in the script.
Mr_Noodle
Site Admin
 
Posts: 12000
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Do not assume any environment variables are set. That includes PATH so specify full paths or setup PATH yourself in the script.

Ah ha, that was, in fact, the problem. It's working great now, thank you very much! :D
tachoknight
 
Posts: 2
Joined: Thu Aug 21, 2025 5:11 pm


Return to Support

cron