#!/bin/bash parser="$(echo $PWD | rev)" IFS=" " partist="$(echo $parser | cut -f 2 -d '/' | rev)" palbum="$(echo $parser | cut -f 1 -d '/' | rev)" pgenre="$(echo $parser | cut -f 3 -d '/' | rev)" if [ "$partist" == "" ] || [ "$palbum" == "" ] || [ "$pgenre" == "" ]; then echo "This script expects a format of "'$MUSICBASEPATH'"/Genre/Artist/Album/Song.ext" exit; fi echo Expected metadata: echo Artist: $partist echo Album: $palbum echo Genre: $pgenre echo for i in $@; do echo Checking "$i" if [ ! -f "$i" ]; then echo File doesn\'t exist. $i continue; fi fartist="$(exiftool -Artist "$i" | sed 's/^Artist\s\+:\s\+//')" falbum="$(exiftool -Album "$i" | sed 's/^Album\s\+:\s\+//')" fgenre="$(exiftool -Genre "$i" | sed 's/^Genre\s\+:\s\+//')" unset tags if [ "$partist" != "$fartist" ] || [ "$falbum" != "$palbum" ] || [ "$fgenre" != "$pgenre" ]; then echo Found artist \[$fartist\] echo Found album \[$falbum\] echo Found genre \[$fgenre\] echo Updating... mid3v2 -a "$partist" -A "$palbum" -g "$pgenre" "$i" &>/dev/null echo fi done