I have all of my CD collection stored as MP3 files. As part of this system, I have several Perl scripts which rely upon the MP3 tag in order to perform certain processes. As I was testing these scripts, I discovered that (for whatever reason) many of the MP3 files did not contain MP3 tag information.

The following script creates a file of all MP3 files which don't have MP3 tag information. This file can then be passed to another script for further processing.

The script is quick and dirty, is of obvious limited usefulness and could probably be coded more cleanly. However, it works and it works well. I'm just posting it here (1) because once again, Perl has the solution to my problem, and (2) in the hopes that others may find it useful.

Comments and improvements are most welcome.

#!/usr/bin/perl use strict; # only these fields need to be changed @ARGV = qw(/music/mp3/); # where MP3 files are located my $outfile = "$ENV{HOME}/mp3/NoTag"; # where to write the output # nothing below here needs to be changed open (MP3, "> $outfile") || die "can't open MP3: $!"; use File::Find; use MPEG::MP3Info; &File::Find::find(\&check, @ARGV); exit; sub check { if ($File::Find::name !~ /\.mp3$/) { return; } my $tag = get_mp3tag($File::Find::name); if (!($tag)) { # if no id tag, print print MP3 "$File::Find::name\n"; } }

If things get any worse, I'll have to ask you to stop helping me.


In reply to Identifying MP3 files with no MP3 tag by shockme

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.