I am trying to create a folder action to compress images with guetzli. I am watching the images folder and if there is an image without 'compp' in filename I run guetzli on it. Here is the script. It works great if I run it from automator but when I save it, it goes in an infinite loop and creates multiple version of the same file and adds compp
to it, i.e `test-compp.jp, test-compp-compp.jpg'. Not sure what I am missing.
for img in "$@"
do
filename=${img%.*}-compp
/usr/local/Cellar/guetzli/1.0.1/bin/guetzli --quality 85 "$img" "$filename.jpg"
echo "$img"
done