Skip to content

Instantly share code, notes, and snippets.

@kentcdodds
Created March 12, 2013 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kentcdodds/5148211 to your computer and use it in GitHub Desktop.
Save kentcdodds/5148211 to your computer and use it in GitHub Desktop.
Read ID3v2 tags from an MP3 file
#!/usr/bin/perl
use MP3::Tag;
$mp3 = MP3::Tag->new(@ARGV[0]); # create object
$mp3->get_tags(); # read tags
print "Attempting to print tags for @ARGV[0]\n";
if (exists $mp3->{ID3v2}) {
print "Comments: " . $mp3->{ID3v2}->comment . "\n";
print "Zip: " . $mp3->{ID3v2}->album . "\n";
print "Tags: " . $mp3->{ID3v2}->title . "\n";
} else {
print "@ARGV[0] does not have ID3v2 tags\n";
}
$mp3->close(); # destroy object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment