diff --git a/refactor_music_library.sh b/refactor_music_library.sh index 55a5cd3..c9508d5 100755 --- a/refactor_music_library.sh +++ b/refactor_music_library.sh @@ -66,11 +66,18 @@ mkdir -pv "$NEW" "$INT" ## Convert Media ## -echo "* Convert all files to mp3." -find "$OLD" ! -name "*".mp3 | while read file; do +echo "* Ensure all files are mp3." +find "$OLD" -type f ! -name "*".mp3 | while read file; do + echo "** Working on '$file'." ffmpeg -nostdin -hide_banner -loglevel quiet -i "$file" "$file".converted.mp3 + status="$?" + if [[ $status != 0 ]]; then + echo "*** FAILED: Exited with status '$status'." + else + echo "*** Success!" + fi done -echo "** Done converting mp3s." +echo "** Done converting any mp3s." ## Transform Media ## @@ -78,7 +85,7 @@ function migrate_music { file="$1" command="$2" - if [[ -z $file ]]; then + if [[ -z "$file" ]]; then echo "ERROR: No filename retrieved, cannot migrate." return 1 fi @@ -143,7 +150,7 @@ function migrate_music { echo "*** Year=$year" parent="" - if [[ -s $year && -s $album ]]; then + if [[ -n $year && -n $album ]]; then parent="$year - $album" else parent="$year$album" @@ -187,11 +194,11 @@ function migrate_music { # Prefer Artist, then Band, then Albumartist grandparent="" - if [[ -s $album ]]; then + if [[ -n $album ]]; then grandparent="$album" - elif [[ -s $band ]]; then + elif [[ -n $band ]]; then grandparent="$band" - elif [[ -s $album_artist ]]; then + elif [[ -n $album_artist ]]; then grandparent="$album_artist" else grandparent="Unknown"