diff --git a/refactor_music_library.sh b/refactor_music_library.sh index b2a1e5b..94563f7 100755 --- a/refactor_music_library.sh +++ b/refactor_music_library.sh @@ -249,18 +249,18 @@ function migrate_music { new_file="$NEW_DIR/$new_file" $command -v "$file" "$new_file" - echo -e "*** Finished file!\n" + echo "*** Finished file!" } ## Main ## # Convert Media # -echo "* Ensure all files are mp3." -find "$OLD_DIR" -type f ! -name "*".$EXT | sort | while read file; do - echo "** Working on '$file'." +echo -e "\n* Ensure all files are mp3." +find "$OLD_DIR" -type f ! -name "*".$EXT | sort | while read non_mp3; do + echo "** Working on '$non_mp3'." - temp_file="`basename "$file"`" + temp_file="`basename "$non_mp3"`" temp_file="$INT_DIR/${temp_file//[^[:alnum:][:space:].]/}.$EXT" echo "temp_file='$temp_file'" @@ -269,14 +269,14 @@ find "$OLD_DIR" -type f ! -name "*".$EXT | sort | while read file; do # Actual conversion. ffmpeg -y \ -nostdin -hide_banner -loglevel quiet \ - -i "$file" "$temp_file" + -i "$non_mp3" "$temp_file" status="$?" fi if [[ $status != 0 ]]; then echo "*** FAILED: Exited with status '$status'." echo "**** To troubleshoot, try running this:" - echo "ffmpeg -y -i \"$file\" \"$temp_file\"" + echo "ffmpeg -y -i \"$non_mp3\" \"$temp_file\"" exit fi echo "*** Success!" @@ -284,12 +284,16 @@ find "$OLD_DIR" -type f ! -name "*".$EXT | sort | while read file; do echo "*** Moving file to NEW." migrate_music "$temp_file" $cmd - echo "*** Removing original." + echo "** Removing original." + echo "$temp_file" + echo "$non_mp3" if [[ -d ~/TRASH ]]; then - mv -v "$file" ~/TRASH/ + mv -v "$non_mp3" ~/TRASH/ else - rm -v "$file" + rm -v "$non_mp3" fi + + echo -e "\n" done echo "** Done converting any mp3s." @@ -299,4 +303,5 @@ rm -rfv "$INT_DIR" echo "* Copying OLD files to NEW." find "$OLD_DIR" -name "*".$EXT | sort | while read file; do migrate_music "$file" $cmd + echo -e "\n" done