Taming Your Music Collection: File Structure

Plan & Setup
     The most important part of any software project is to plan out beforehand what the requirements for your application are and how you plan to solve each one. A lot of first-time software developers make the mistake of jumping straight in to writing code. This is similar to smoking cigarettes. It will make you feel cool but it will be terrible for you in the long run. Planning out your software before writing it will save you hours of rewriting when you inevitably realize you forgot to include some functionality you wanted. Let’s get to planning then.
  1. Given a directory, we need to be able to list all mp3 files in that directory.
    • Need to be able to pass a directory to the program as a command line parameter.
    • If the directory contains another directory, we may need to read its contents as well. This will require using recursion and could be an optional feature passed as a command line argument later on.
  2. We need to iterate over each file and read its contents.
    • Need to devise some technique or employ some pre-built module for reading id3 data from mp3 files.
    • Need to also remove any unwanted id3 tags. I don't want to see genre tags, so I will remove them if they exist.
  3. Rename the file according to some predefined pattern for how we want our mp3 files to look. For example: 01. Artist - Song Name.mp3
  4. Save the file to a path that reflects our desired music organization structure. For example: /Music/Artist/Album/01. Artist - Song Name.mp3.
    • We will need to specify some location in which to save the newly formatted file.
     I'm using Linux but you can install Python on Windows very easily. You can download Python in multiple formats, including Windows and Mac, at http://www.python.org/download/releases/. I won't detail how to install it as there are many articles on the Internet on how to do so. If you have troubles getting it installed, consider switching to Linux. It was already installed on my system on day 1.

     I will, however, describe how to install (on Linux) at least one of the modules we will be using for reading and manipulating id3 tags--Mutagen:
  1. Head over to http://code.google.com/p/mutagen/downloads/list and download Mutagen to your system.
  2. Extract the contents of the file:
    $ tar -xzvf mutagen-1.20.tar.gz
  3. Install the Mutagen module:
    $ ./setup.py build $ su -c "./setup.py install"
Boy that was easy. I hope the Windows installation is as simple. If not, feel free to try Linux.