#!/usr/bin/perl -w use strict; use MP3::Info; use Getopt::Long; use vars qw($tag $value); my %value; my $flag; my @field = qw(title artist album year comment genre tracknum); @value{@field} = ('') x @field; GetOptions(map { $_.'=s',\$value{$_} } keys %value); my $file = shift or USAGE() and exit; my $tag = get_mp3tag($file) or warn "no ID3 tag for '$file'"; for (keys %value) { next unless $value{$_}; $tag->{uc $_} = $value{$_}; $flag = 1; } set_mp3tag($file,$tag) if $flag; write_tag($tag); sub write_tag { my %tag = %{+shift}; write while ($tag,$value) = each %tag; } sub USAGE { print "USAGE: $0 [options] file\noptions:\n"; print map { "\t-$_\n" } @field; } format STDOUT = @<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $tag,$value . __END__ =pod =head1 NAME id3_tweaker.pl - MP3::Info script =head1 DESCRIPTION This is a simple script that uses MP3::Info to alter the a single ID3 tag fields or multiple ID3 tag fields. There is no -help or -h option, just run the script by itself for the USAGE. =head1 SYNOPSIS for *nix: ./id3_tweaker.pl -year='1984' foo.mp3 for win32: perl id3_tweaker.pl -year='1984' foo.mp3 or run with the only argument being the file: ./id3_tweaker.pl foo.mp3 retrieve list of tags that can be altered: ./id3_tweaker.pl =cut