Easily Sort Your Music Library

Here is a very simple script to sort your whole music library according to their artists,

#!/bin/bash
# sortMusic v0.4
# make sure this script in in the music directory and you execute this script from there
# know issue: will display many errors, but it does it fine, those errors are not to be bothered about
# still needs a workaround
echo "$(ls -l *.mp3 | wc -l) Files will be sorted according to their Artists"
echo "Make sure all your song artists are correct, will wait for 3 seconds..."
sleep 3
for i in ./*; do
	artist=$(mp3info "$i" | sed -n 's/Artist: *//p')
	if [ -d "$artist" ]; then
		mv "$i" "$artist"
	else
		mkdir "$artist"
		mv "$i" "$artist"
	fi
done
# To move all the incorrect id3 artists
mkdir "Z Singles Z"
mv *.mp3 "Z Singles Z"

# That was very simple, wasn't it?

Just make a file called sortMusic-v0.4 in your main music folder, paste the above code into that file, then do $ chmod +x sortMusic-v0.4 and then do a $ ./sortMusic-v0.4 in the music folder. Please download mp3info as this uses that package. Please note that this is very case-sensitive, so if your artists are same but differ in case, it will make a new directory for that one, so please take care until I have a workaround for this.