I've created a simple service using automator, that takes a *.tiff, creates a *.jpg out of it and than deletes the original.
However, I run this on a *.tiff file, it keeps on running, meaning it keeps on converting the (then jpg) file over and over again. That is, I believe it does, since the file disappears and reappears about 2 times a minute and the timestamp changes. How do I tell it to run the service (i.e. the shell commands) just once?
The Service in Automator is just this one action of type "run Shell-Script". The Shell script is
newName=${@%.tiff}.jpg
echo "$newName"
sips -s format jpeg "$@" --out "${newName}"
rm "$@"
Thanks! (Would have posted a picture of the Automator window, but was not allowed to)
This behavior seems to be a folder actions.
if you created a folder action :
1- You must filter the TIFF files for that folder action doesn't process the created JPEG file.
2- You must use a loop, if you drop one or more files in that folder.
3- Use "&&" to delete the TIFF file only when the sips command finishes successfully.
Here's the script:
for f in "$@";do
if [[ "$f" = *.tiff ]]; then
sips -s format jpeg "$f" --out "${f%.tiff}.jpg" && rm "$f"
fi
done