Sometimes mp3 files come with a plethora of tags. Some of them contain unnecessary information.
Here is a script that removes unwanted tags. The unwanted tags are stored in an array.

#!/usr/bin/perl # # use strict; use warnings; use strict; use Getopt::Std; use File::Find::Rule; use MP3::Tag; use utf8; MP3::Tag->config( write_v24 => 1 ); our $opt_d; my $opt_string = 'd:'; getopts( 'd:', $opt_d ) or usage(); my $dir = $opt_d; die "$!: $dir\n" unless (-d $dir); my @unwanted_tags = qw (COMM COMM01 COMM02 COMM03 MCDI PRIV PRIV01 PRIV02 PRIV03 PRIV04 +PRIV05 PRIV06 TBPM01 TMED TPUB TSSE TXXX TXXX01 TXXX02 TXXX03 TXXX04 +TXXX05 TXXX06 TXXX07 TXXX08 TXXX09 TXXX10 WCOM WXXX); my %unwanted_tags = map { $unwanted_tags[$_] => 1 } 0 .. $#unwanted_tags; my $rule = File::Find::Rule->file->name("*.mp3")->start( $dir ); while ( defined ( my $file = $rule->match ) ) { my ( $album, $artist, $title ); my $mp3 = MP3::Tag->new($file); $mp3->get_tags(); if ( exists $mp3->{ID3v2} ) { my $id3v2 = $mp3->{ID3v2}; my $frameIDs_hash = $id3v2->get_frame_ids(); if ($frameIDs_hash) { foreach my $frame ( keys %$frameIDs_hash ) { if ( $unwanted_tags{$frame} ) { print "$file\n"; print "Unwanted Frame: $frame found\n"; $id3v2->remove_frame($frame); $id3v2->write_tag(); } } } } } sub usage { print "Please provide parent directory\ne.g. perl remove_unwanted_tags.pl -d + DIRECTORY\n"; exit; }

BTW:
10 years ago I joined the monastery. Today I received a HappyMonks day greeting. That's a nice idea, and a thought it is a good occasion to share a script I wrote recently.


In reply to Remove unwanted MP3 tags by walto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.