You are here: Matthew KENWORTHY > Nelse > Organising my music collection

Organising my music collection


I wanted to organise all the random music files that I have lying around on all my computers, and keep them in one location that was consistently backed up and that I could reach them from any networked connection in the world.

I have three sets of music file types:

There are three goals:

  1. Have a consistent directory layout for all files
  2. Have metadata in the music files
  3. Set all files with album cover art for every music file
  4. Make it so that iTunes and most popular music players get the correct information on their displays.

Here's how I've been tackling these tasks:

Consistent directory structure

Each album is structured by Artist, Album, Music file:

./the_avalanches/since_i_left_you/04-frontier_psychiatrist.mp3

All filenames and directory names are lower case (a-z), numerical (0-9) and the three characters:

  1. a period, or full stop: .
  2. a dash: -
  3. an underscore: _

For albums, the filename is a zero-padded track number, a dash, and the name of the song. Nominally spaces are replaced by an underscore, and the dash acts as a field separator.

Three types of music file:

  1. Classic album, with one band/artist and a collection of music tracks.
  2. Singles.
  3. Classical music tracks.
  4. Compilation albums, which have individual artist/track combinations.

I used the linux ''find'' command to root out the mp3's I had around on my drive.

find -type f -name "*.mp3"

To get a file count, pipe it through the command ''wc''

find -type f -name "*.mp3" | wc -l

tr A-Z a-z

Cover finding album art:

http://mookooh.org/coverfinder/

Various options for editing tags in music files:

Taglib

Located at http://developer.kde.org/~wheeler/taglib.html and installed on a Mac with:

sudo port install taglib-sharp

From: http://www.macosxhints.com/article.php?story=20050820184012686

If you are submitting tags to CDDB or other online source hold to the convention used by the iTunes Music Store (and Amazon) for classical music.

That convention is:

So This Album would be:

my $mp3 = Audio::TagLib::MPEG::File->new($outfile);
my $id3v2 = $mp3->ID3v2Tag(1);
$id3v2->setArtist(Audio::TagLib::String->new($artist));
$id3v2->setAlbum(Audio::TagLib::String->new($album));
$id3v2->setTitle(Audio::TagLib::String->new($title));
$id3v2->setYear($date);
$id3v2->setTrack($track);
$id3v2->setGenre(Audio::TagLib::String->new($genre));
if (open(PICFILE, "$flacdir/cover.jpg")) {
$filesize = (-s PICFILE);
binmode(PICFILE);
read(PICFILE, $imgdata, $filesize);
close(PICFILE);
my $imgbv = Audio::TagLib::ByteVector->new();
$imgbv->setData($imgdata,$filesize);
my $bv = Audio::TagLib::ByteVector->new("APIC");
my $field =
Audio::TagLib::ID3v2::AttachedPictureFrame->new($bv, "UTF8");
$field->setPicture($imgbv);
$field->setTextEncoding("UTF8");
$field->setMimeType(Audio::TagLib::String->new("image/jpeg"));
$field->setType("Other");
$field->setDescription(Audio::TagLib::String->new("Cover
(front)"));
$id3v2->addFrame($field);
}
$mp3->save();

BINGO!!! This is what I've been looking for - a very similar workflow for me:

http://www.mfischer.com/2007/11/21/mp3-metadata-tagging/