From 0f83256e05a61d167b21b59361782f1948d843d0 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Wed, 19 Mar 2025 07:42:43 -0700 Subject: [PATCH] Pull the remaining needed information. --- refactor_music_library.sh | 77 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) mode change 100644 => 100755 refactor_music_library.sh diff --git a/refactor_music_library.sh b/refactor_music_library.sh old mode 100644 new mode 100755 index bd3ddb2..55a5cd3 --- a/refactor_music_library.sh +++ b/refactor_music_library.sh @@ -102,7 +102,7 @@ function migrate_music { new_file="$title$EXT" - # Retrieve and clean the Track# + # Retrieve and clean the Track Number track="" # Get raw value track="`exiftool -Track "$file"`" @@ -120,19 +120,90 @@ function migrate_music { new_file="$track. $new_file" # Add the Album and Year. + album="" + album="`exiftool -Album "$file"`" + album="${album//Album /}" + album="${album// : /}" + album="${album//[^[:alnum:][:space:].]/}" + album="`echo $album`" + while [[ "$album" == *" "* ]]; do + album="${album// / }" + done + echo "*** Album=$album" + year="" + year="`exiftool -Year "$file"`" + year="${year//Year /}" + year="${year// : /}" + year="${year//[^[:alnum:][:space:].]/}" + year="`echo $year`" + while [[ "$year" == *" "* ]]; do + year="${year// / }" + done + echo "*** Year=$year" + + parent="" + if [[ -s $year && -s $album ]]; then + parent="$year - $album" + else + parent="$year$album" + fi new_file="$parent/$new_file" - # Add the Artist and Genre. + # Add the Artist. + artist="" + artist="`exiftool -Artist "$file"`" + artist="${artist//Artist /}" + artist="${artist// : /}" + artist="${artist//[^[:alnum:][:space:].]/}" + artist="`echo $artist`" + while [[ "$artist" == *" "* ]]; do + artist="${artist// / }" + done + echo "*** Artist=$artist" + band="" + band="`exiftool -Band "$file"`" + band="${band//Band /}" + band="${band// : /}" + band="${band//[^[:alnum:][:space:].]/}" + band="`echo $band`" + while [[ "$band" == *" "* ]]; do + band="${band// / }" + done + echo "*** Band=$band" + + album_artist="" + album_artist="`exiftool -Albumartist "$file"`" + album_artist="${album_artist//Albumartist /}" + album_artist="${album_artist// : /}" + album_artist="${album_artist//[^[:alnum:][:space:].]/}" + album_artist="`echo $album_artist`" + while [[ "$album_artist" == *" "* ]]; do + album_artist="${album_artist// / }" + done + echo "*** Albumartist=$album_artist" + + # Prefer Artist, then Band, then Albumartist + grandparent="" + if [[ -s $album ]]; then + grandparent="$album" + elif [[ -s $band ]]; then + grandparent="$band" + elif [[ -s $album_artist ]]; then + grandparent="$album_artist" + else + grandparent="Unknown" + fi new_file="$grandparent/$new_file" # Move the file. new_file="$NEW/$new_file" - $command "$file" "$new_file" + $command -v "$file" "$new_file" + echo "*** Finished file!" } echo "* Moving INTERIM files to NEW."