Converting IPTC ratings in EXIF metadata to and from Finder tags in macOS.
0

Configure Feed

Select the types of activity you want to include in your feed.

1.0 kB 26 lines
1#! /usr/bin/env fish 2 3# Takes a Finder tag and turns it into a rating stored in IPTC EXIF metadata. 4# 5# The tags are named "★", "★★", "★★★", "★★★★", and "★★★★★". Behavior if multiple 6# tags are added is undefined. If none of the tags are present, the file will 7# be unchanged. 8# 9# Dependencies: exiftool and tag. Developed with exiftool v13.55 and tag 10# v0.10.0. 11 12for file in $argv 13 set tag_name (tag --list $file | awk '$NF ~ /^★+$/ { print $NF }') 14 if test -n "$tag_name" 15 set rating (string length $tag_name) 16 set current_rating (exiftool -RATING -veryShoft -printFormat '$Rating' -API MissingTagValue=0 $file) 17 if test $rating -ne $current_rating 18 echo "Rating $file (tagged: $tag_name) as $rating" 19 exiftool -overwrite_original_in_place -Rating=$rating $file 20 else 21 echo "Not changing rating of $file (tagged: $tag_name, rating: $rating)" 22 end 23 else 24 echo "Not tagging $file because of missing or 0 rating." 25 end 26end