Page 1 of 1

Running shell script with ImageMagick on files

PostPosted: Thu Aug 21, 2025 5:35 pm
by tachoknight
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

Re: Running shell script with ImageMagick on files

PostPosted: Fri Aug 22, 2025 8:29 am
by Mr_Noodle
Do not assume any environment variables are set. That includes PATH so specify full paths or setup PATH yourself in the script.

Re: Running shell script with ImageMagick on files

PostPosted: Fri Aug 22, 2025 10:02 am
by tachoknight
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