[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MP3 ID3 Tags



Tim wrote:
> Does anyone have a proven method of doing mass id3 tag changes on mp3
> files? I want to do it so that any in dir XXX/* and all subdirs get the
> same Genre tag...

Have you looked at any of the Perl MP3 modules on CPAN?

MP3::ID3v1Tag sounds like what you are looking for.

http://search.cpan.org/doc/SVANZOEST/MP3-ID3v1Tag-1.11/lib/MP3/ID3v1Tag.pm

#!/usr/local/bin/perl
use File::Find;
use MP3::ID3v1Tag;

my @directories_to_search = @ARGV;
find (\&wanted, @directories_to_search);
sub wanted {

  return unless m/\.mp3$/i; # Skip unless it has an MP3 extension

  my $mp3_file = MP3::ID3v1Tag->new($_);
  return unless $mp3_file; # Done if not an MP3 file
  return unless $mp3_file->got_tag; # Done if no tag

  my $genre = $mp3_file->get_genre(); # Get the current tag

  $mp3_file->set_genre("Blues"); # Set the tag by name
  $mp3_file->set_genre_num(0);   # Or use the genre numbers

  my $save_status = $mp3_file->save; # Save the changes

  print "$File::Find::name updated\n"; # Tell the user
}
1;

Mike808/
-- 
() Join the ASCII ribbon campaign against HTML email and Microsoft-specific
/\ attachments. If I wanted to read HTML, I would have visited your website!
Support open standards.

-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.