Search:  
Gentoo Wiki

TIP_Organizing_digital_music

Contents

Intro

Organize

You will need to install the Audio::File Perl Module before running this script. Either login/su to root or use sudo to use the cpan command. If you have not done this before, you may be required to setup CPAN. Once you have successfully configured CPAN, you should use the command reload index and reload cpan to update your CPAN indeces. Once this is done, you may type install Audio::File.
Note: This installation kept bombing out on me, so I ended up ignoring make errors. Once installed, despite errors, this script worked flawlessly. --destuxor

Now save the following code as somefile.pl, make it executable with the command chmod u+x somefile.pl, and then execute it by typing ./somefile.pl. Run this script in the directory containing your MP3s. Alternatively, save it in /usr/local/bin/ and just call somefile.pl from anywhere.

This script was originally posted on LinuxQuestions.org.

#!/usr/bin/perl -w
# Run this script to organize music files in your current working directory
# by artist/album/file.
use strict;
use warnings;

use Audio::File::Flac::Tag;
use Audio::File::Ogg::Tag;
use Audio::File::Mp3::Tag;

my @Mp3 = glob "*.mp3";
my @Flac = glob "*.flac";
my @Ogg = glob "*.ogg";

my $x;

foreach $x (@Mp3)
{
  my $song = Audio::File::Mp3::Tag->new($x);
  my ($artist, $album) = ($song->artist, $song->album);
  if (defined($artist) and defined($album))
  {
    if (!(-d "$artist"))
    {
      mkdir "$artist";
    }
    if (!-d "$artist/$album")
    {
      mkdir "$artist/$album";
    }
    rename ($x, "$artist/$album/$x");
    printf ("Moved $x to $artist/$album/$x\n");
  }
  else
  {
    printf ("%s was skipped because it does not have readable ID3 tags.\n", $x);
  }
}

foreach $x (@Flac)
{
  my $song = Audio::File::Flac::Tag->new($x);
  my ($artist, $album) = ($song->artist, $song->album);
  if (defined($artist) and defined($album))
  {
    if (!(-d "$artist"))
    {
      mkdir "$artist";
    }
    if (!-d "$artist/$album")
    {
      mkdir "$artist/$album";
    }
    rename ($x, "$artist/$album/$x");
    printf ("Moved $x to $artist/$album/$x\n");
  }
  else
  {
    printf ("%s was skipped because it does not have readable ID3 tags.\n", $x);
  }
}

foreach $x (@Ogg)
{
  my $song = Audio::File::Ogg::Tag->new($x);
  my ($artist, $album) = ($song->artist, $song->album);
  if (defined($artist) and defined($album))
  {
    if (!(-d "$artist"))
    {
      mkdir "$artist";
    }
    if (!-d "$artist/$album")
    {
      mkdir "$artist/$album";
    }
    rename ($x, "$artist/$album/$x");
    printf ("Moved $x to $artist/$album/$x\n");
  }
  else
  {
    printf ("%s was skipped because it does not have readable ID3 tags.\n", $x);
  }
}

Note: I wrote another script which only handled MP3's (you might be able to force MP3::Tag to read other files which use ID3 tags). You may find this other script useful as you may be surprised how many MP3s, even the ones you ripped yourself, do not have standard ID3 tags or the tags may be corrupt. --destuxor

Tag

Cowbell

http://www.more-cowbell.org/

You'll need to install a bunch of mono / C# related programs with ~x86 or possible unmasked in order to get this to work, but it works. The gui doesn't seem particularly useful as it can only retag/rename one album at a time, but the commandline tool looks promising. It would be nice to see this as a part of a more functional jukebox app -- like banshee (similar to rhythmbox, but in C#).

Though, it does have a batch mode -- so coupled with that perl script[2] it might do the trick.

Other

  • media-sound/qmbtagger
  • media-sound/SmarTagger
  • media-sound/audiotag
    • Available versions: ~0.12 0.13 ~0.14
    • Homepage: http://tempestgames.com/ryan/
    • Description: A command-line audio file meta-data tagger. Sets id3 and/or vorbis tags in mp3, ogg, and flac files.
  • media-sound/easytag
  • media-sound/lltag
    • Available versions: 0.10 ~0.11
    • Homepage: http://home.gna.org/lltag/
    • Description: Automatic command-line mp3/ogg/flac file tagger and renamer
  • Picard Homepage
    • 0.9.0 PicardQT is now in layman overlay, it is very beta though.
layman -f -a musicbrainz

See Also


Last modified: Thu, 04 Sep 2008 06:20:00 +0000 Hits: 4,879