diff --git a/refactor_music_library.sh b/refactor_music_library.sh index b09fb2e..fd6720b 100755 --- a/refactor_music_library.sh +++ b/refactor_music_library.sh @@ -28,7 +28,7 @@ INT="INTERIM" OLD_DIR="$DIR/$OLD" NEW_DIR="$DIR/$NEW" -INT_DIR="$DIR/$INTERIM" +INT_DIR="$DIR/$INT" ## Checks and Setup ## @@ -74,13 +74,23 @@ mkdir -pv "$NEW_DIR" "$INT_DIR" echo "* Ensure all files are mp3." find "$OLD_DIR" -type f ! -name "*".mp3 | sort | while read file; do echo "** Working on '$file'." + + TEMP_DIR="`dirname "$file"`" + TEMP_DIR="${TEMP_DIR//$OLD/$INT}" + echo "TEMP_DIR='$TEMP_DIR'" + mkdir -pv "$TEMP_DIR" + + TEMP_FILE="`basename "$file"`" + TEMP_FILE="${TEMP_FILE//[^[:alnum:][:space:].]/}" + echo "$TEMP_FILE" + ffmpeg -y -nostdin -hide_banner -loglevel quiet -i "$file" \ - "${file//$OLD/$INTERIM}".converted.mp3 + "${file//$OLD/$INT}".mp3 status="$?" if [[ $status != 0 ]]; then echo "*** FAILED: Exited with status '$status'." echo "**** To troubleshoot, try running this:" - echo "ffmpeg -i \"$file\" \"$file\".converted.mp3" + echo "ffmpeg -y -i \"$file\" \"${file//$OLD/$INT}\".mp3" else echo "*** Success!" fi