Linux MP3 Sort Script & Organizing Media on Linux using Scripts

Page content

Before You Begin…

Many computer users find themselves baffled by how many music files they accumulate—and precisely how unorganized they are. Torrents, CD rips, flash drive exchanges, downloads from emails—they all get hopelessly confused on the hard drive, to the point where it may seem impossible to ever find that file you’re looking for.

While there are many programs out there for Windows and Mac users to sort their mp3s, many Linux users find themselves without such tools—because Linux doesn’t need them. While there is some organizational tools built into music players like Amarok and Rhythmbox, it’s hard to match the quick and easy power of a script.

Maybe not all your files are .mp3s, however. Since most .mp3 sort scripts do not include parts with which to convert files, it might be a good idea to first run your media library through some sort of conversion program to get them all in the same file type. Of course, many Linux users prefer other file types, like .ogg, in which case it is a simple matter to modify any script to suit the different file extension. Whatever your preferred file type, homogeneity is best and will make the rest of the process smoother.

How They Work

How most mp3 sort scripts work is by first reading the ID3 tag of the mp3 file, to retrieve the band name, CD title, and the name of the song. ID3 tags also include other useful data like the year, track number and genre, which may be included into the sort script if desired. These ID3 tags will then be used to rename the mp3 file, usually to something simple and readable like bandname/cdtitle/song.mp3, though this will obviously vary depending on your choice format.

Then, the actual organization. Many mp3 scripts will also create a directory structure based on the ID tags. Typically, the first directory is organized by band, then by CD, and then by song. This will allow your music to be quickly and efficiently navigated to find your music files. If one wanted some other system of organization, perhaps creating directories based on genre, for instance, this is an easy change to make as well.

There are a number of scripts available online, both user generated and merely posted on forums, and somewhat more formal scripts available for download. My personal favorite of the formal downloads is offered through the Linux Softpedia,though many Linux forums also provide scripts that may be more suited to your particular needs (for example here.) If you’d just like to manipulate the ID3 data for files, the command line utility id3tool may suit your needs as well. There are hundreds of little user-created scripts floating around on the Internet, some of which are compiled into application listings like here at

Once you have the script, they are easy to customize. If you want to organize your music by other ID3 categories, for example by genre, or to name the .mp3 file differently, for example including the track number, it will take mere moments on a keyboard and a little scripting know-how to fit these scripts to your precise needs.

It’s probably a good idea to do this sorting every so often as your .mp3 collection expands to keep things organized. It only take a few minutes, and the knowledge that you know where all your music files are is well worth it.