#!/usr/bin/env bash # 2025 Hyperling # Clean up a music library. # Steps: # 0) Ensure an OLD folder exists, it is what will be refactored. # 1) Convert all non-mp3 files to mp3 and put them in an INTERIM folder. # 2) Loop over all OLD and INTERIM's mp3 files and move them to NEW based on data. # - Name the file as "${ZERO_LED_TRACK_NUMBER}. ${SONG_TITLE} # - Name parent folder as "${YEAR} - ${ALBUM}" if both exist, otherwise just one or the other "${YEAR}${ALBUM}". # - Name grandparent folder as "${ARTIST} - ${GENRE}" if both exist, otherwise "${ARTIST}${GENRE}". # TODO List # - Organize tracks by Artist + Album folders. # - Name parent folder as "$YEAR - $ALBUM" if both exist, otherwise just one or the other. # - Name grandparent folder as ARTIST if it exists, otherwise GENRE. # If we are in OLD, go up one level. if [[ "`pwd`"== */OLD ]]; then cd .. fi if [[ ! -d OLD ]]; then echo "ERROR: Could not find a folder named 'OLD', please create it and add your library there." fi echo "Convert m4a's to mp3's." ls *.m4a | while read m4a; do ffmpeg -nostdin -hide_banner -loglevel quiet -i "$m4a" "$m4a".mp3; done