A
ads
I am trying to write a script that seems to be working fine, except
iTunes (or WinAmp) can't modify the ID3 tag, I am running the script on
Linux and am sure there is something wrong in how I am writing the
file. The wierd part is both applications appear to be reading the file
correctly, but not able to modify or convert the tags. Can anyone see
anything stupid I am doing? I think there is a method to close or
complete things that I am not calling.
inputs are mp3 files in the form:
Chapter 1.mp3
Chapter 2.mp3
....
Thanks,
Tim
#!/usr/bin/perl
use MP3::Tag;
$mydir = $ARGV[0];
print "Using the directory $mydir\n";
print "please enter the author's name: ";
$auth_name = <STDIN>;
print "please enter the pub year: ";
$intYr = <STDIN>;
print "please enter the title: ";
$title = <STDIN>;
while ($filename = <$mydir/*.mp3> ) {
$filename =~ /\d+/;
$number = $&;
# need the file name without the directory
$filename =~ /\//;
$filename = $';
print "Processing $filename with number $number\n";
# create new MP3-Tag object
$mp3 = MP3::Tag->new($filename);
$mp3->get_tags();
# if an existing tag exists, delete it
if (exists $mp3->{ID3v2}) {
$id3v2 = $mp3->{ID3v2};
$id3v2->remove_tag();
}
# create new tag for a fresh start
$id3v2 = $mp3->new_tag("ID3v2");
# now assign values
# $id3v2->add_frame("TPOS", "$number\/25");
$id3v2->add_frame("TPE1", $auth_name);
$id3v2->add_frame("TYER", $intYr);
# $id3v2->add_frame("TCP", "$number");
$id3v2->add_frame("TALB", $title);
$id3v2->add_frame("TIT2", "$filename");
$id3v2->add_frame("TCON", "Books & Spoken");
$id3v2->write_tag();
# clean up
$mp3->close();
}
iTunes (or WinAmp) can't modify the ID3 tag, I am running the script on
Linux and am sure there is something wrong in how I am writing the
file. The wierd part is both applications appear to be reading the file
correctly, but not able to modify or convert the tags. Can anyone see
anything stupid I am doing? I think there is a method to close or
complete things that I am not calling.
inputs are mp3 files in the form:
Chapter 1.mp3
Chapter 2.mp3
....
Thanks,
Tim
#!/usr/bin/perl
use MP3::Tag;
$mydir = $ARGV[0];
print "Using the directory $mydir\n";
print "please enter the author's name: ";
$auth_name = <STDIN>;
print "please enter the pub year: ";
$intYr = <STDIN>;
print "please enter the title: ";
$title = <STDIN>;
while ($filename = <$mydir/*.mp3> ) {
$filename =~ /\d+/;
$number = $&;
# need the file name without the directory
$filename =~ /\//;
$filename = $';
print "Processing $filename with number $number\n";
# create new MP3-Tag object
$mp3 = MP3::Tag->new($filename);
$mp3->get_tags();
# if an existing tag exists, delete it
if (exists $mp3->{ID3v2}) {
$id3v2 = $mp3->{ID3v2};
$id3v2->remove_tag();
}
# create new tag for a fresh start
$id3v2 = $mp3->new_tag("ID3v2");
# now assign values
# $id3v2->add_frame("TPOS", "$number\/25");
$id3v2->add_frame("TPE1", $auth_name);
$id3v2->add_frame("TYER", $intYr);
# $id3v2->add_frame("TCP", "$number");
$id3v2->add_frame("TALB", $title);
$id3v2->add_frame("TIT2", "$filename");
$id3v2->add_frame("TCON", "Books & Spoken");
$id3v2->write_tag();
# clean up
$mp3->close();
}