Penguin
Note: You are viewing an old revision of this page. View the current version.

Sort a directory of mp3s into directories like Artist/Album Name/

for i in *.mp3; do ALBUM=`id3tool "$i" | grep Album | cut -d " " -f 3 | \

sed s/" "*$// `; ARTIST=`id3tool "$i" | grep Artist | cut -d " " -f 3 | \ sed s/" "*$// `; "$ARTIST"? && DIR="$ARTIST/"; "$ALBUM"? && DIR=${DIR}${ALBUM}/; "$DIR"? && (mkdir -p "$DIR"; mv "$i" "$DIR/") ; done

It uses id3tool to pull out the album and artist name, it strips some extra crap out of this (unneeded whitespace), then it creates the directory and moves the mp3 into that dir.

Note that using 'for i in *.mp3' works even if you have spaces in the filename.