-# if we remove a track from a playlist in navidrome,
-# beet subsonicplaylist won't remove corresponding beet
-# smart attribute, so clear them all here.
+for plist in ${nav_tags[@]}; do
+ echo "processing $plist"
+ # shellcheck disable=SC2016 # expected beets arg
+ beet ls -f '$path' $plist:t $nav_convert_query | sort | sed 's,\.flac$,.mp3,'> p
+ while read -r path; do
+ flac="${path%.mp3}.flac"
+ if [[ ${flacs[$flac]} ]]; then
+ path="$flac"
+ fi
+ m beet modify -y "path:$path" "$plist!"
+ # files unique to tmpf are in beets not navidrome
+ done < <(comm -23 p $plist)
+ while read -r path; do
+ flac="${path%.mp3}.flac"
+ if [[ ${flacs[$flac]} ]]; then
+ path="$flac"
+ fi
+ m beet modify -y "path:$path" $plist=t
+ # files unique to plist are in navidrome not beets
+ done < <(comm -13 p $plist)
+
+done