ExifTool code works in Terminal but not in Hazel. Help Pls!

Hello,
Can someone be kind enough to point me in the right direction, please. I am not coding literate (am an interior designer), so I am totally clueless.
After scavenging the web, I came up with the following concoction that works in the Terminal, but fails in Hazel:
The first part works in Hazel. (I tried running it as a separate rule). Essentially, it grabs a part of the fileName[enclosed in sq. brackets] and passes it along to "tag" the file (https://github.com/jdberry/tag). As I am frequently required to also work in MS Windows, I made a habit of naming files like this: " fileName[tag1 tag2 tag3].ext "
The second part is supposed to take the file's macOS tags and write them as EXIF & IPTC tags to JPEG files. It also prepends the DateTimeOriginal to the fileName. It works on the command line but for some reason is failing in Hazel.
Please guide me.
Thanks so much, & to those reading this post, a Happy New Year!
Harshal
Can someone be kind enough to point me in the right direction, please. I am not coding literate (am an interior designer), so I am totally clueless.
After scavenging the web, I came up with the following concoction that works in the Terminal, but fails in Hazel:
- Code: Select all
opentags=`echo $1 | sed 's/.*\[\([^]]*\)\].*/\1/g'`
for i in $opentags
do
tag -a "$i" "$1"
done
assignedtags=`tag -tg $1|grep '^ '|cut -c5-|sort -u`
echo "$assignedtags" | while IFS= read -r line ; do /usr/local/bin/exiftool -overwrite_original_in_place -P -keywords+="$line" $1; done ; /usr/local/bin/exiftool -overwrite_original_in_place '-keywords<${keywords;NoDups(1)}' '-exif:xpkeywords<${iptc:keywords;NoDups(1)}' -P -d '%Y:%m:%d_%H:%M:%S' '-filename<${FileModifyDate;}_$FileName' '-filename<${GPSDateTime;}_$FileName' '-filename<${MediaCreateDate;}_$FileName' '-filename<${ModifyDate;}_$FileName' '-filename<${DateTimeOriginal;}_$FileName' "$1"
The first part works in Hazel. (I tried running it as a separate rule). Essentially, it grabs a part of the fileName[enclosed in sq. brackets] and passes it along to "tag" the file (https://github.com/jdberry/tag). As I am frequently required to also work in MS Windows, I made a habit of naming files like this: " fileName[tag1 tag2 tag3].ext "
The second part is supposed to take the file's macOS tags and write them as EXIF & IPTC tags to JPEG files. It also prepends the DateTimeOriginal to the fileName. It works on the command line but for some reason is failing in Hazel.
Please guide me.
Thanks so much, & to those reading this post, a Happy New Year!
Harshal