Reputation: 120
Im on MacOS Catalina 10.15.3
Im using the zsh
I want to create a Atomator App, that removes metadata from files for me. The Atomator App works in such a way, that I drag and drop the File on the App, and the App starts a shellscript, with the filepath as input.
Im using exiftools to remove the Meta Data.
I first tested if exiftools works if i use it in the terminal:
And it works.
But when I use exiftool in the shellscript inside my Automator App, then it says, that it didn't found the command "exiftools".
Here is my Automator Workflow:
And the Automation runs this Shellscript:
for f in "$@"
do
echo "$f"
done
xattr -c "$f"
exiftool -all= "$f"
rm -r "$f"_original
I tested it out, and the file path is correctly stored in the $f variable.
But for some reason the shellscript in the Automation can not use the exiftool.
And the second error in the error message is not important, because it appears because the exiftool command didnt run.
This is the error Message of the Automation Application:
------------------------
Thank You very much
Upvotes: 0
Views: 1171
Reputation: 125838
There are several problems with the "solution" script. First, it won't work for multiple files (i.e. select several files in the Finder, then drag them all to the app). It loops over the files, echoing each path, but then it only runs exiftool
on the last one. To make it run on all of them, put the commands that operate on the files inside the for
loop, rather than after it (and remove the echo
-- it's just there as a placeholder in the sample code).
Second, it doesn't do any error checking; if something goes wrong with one of the commands, it blithely continues on, maybe in the wrong directory, maybe who knows. You can use &&
to join commands, and it'll run the second command only if the first one succeeds.
Third, cd
ing around in a script can cause confusion in a script, because it changes the meaning of relative paths (shouldn't be a problem here, but it's generally a bad practice). If you need to refer to a file in a different directory (like the exiftool
executable), it's safer to specify its location by path than to cd
over to it first.
Here's how I'd write the script:
for f in "$@"
do
/Users/niklas/Programming/Tools/ExifTool/exiftool -all= "$f" &&
rm -r "$f_original"
done
Upvotes: 1
Reputation: 120
I solved the problem by moiving the exiftools to a folder in my home directory. Then I let the shellscript move to this directory and execue the exiftool with . /
My shellscript looks now like this:
for f in "$@"
do
echo "$f"
done
cd /Users/niklas/Programming/Tools/ExifTool/
./exiftool -all= "$f"
rm -r "$f"_original
exit
Upvotes: 0