Easily Sort Your Music Library

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

01.#!/bin/bash
02.# sortMusic v0.4
03.# make sure this script in in the music directory and you execute this script from there
04.# know issue: will display many errors, but it does it fine, those errors are not to be bothered about
05.# still needs a workaround
06.echo "$(ls -l *.mp3 | wc -l) Files will be sorted according to their Artists"
07.echo "Make sure all your song artists are correct, will wait for 3 seconds..."
08.sleep 3
09.for i in ./*; do
10.    artist=$(mp3info "$i" | sed -n 's/Artist: *//p')
11.    if [ -d "$artist" ]; then
12.        mv "$i" "$artist"
13.    else
14.        mkdir "$artist"
15.        mv "$i" "$artist"
16.    fi
17.done
18.# To move all the incorrect id3 artists
19.mkdir "Z Singles Z"
20.mv *.mp3 "Z Singles Z"
21. 
22.# 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.

Loading...