Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Identifying MP3 files with no MP3 tag

by shockme (Chaplain)
on Jan 02, 2002 at 00:52 UTC ( #135550=CUFP: print w/ replies, xml ) Need Help??

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.

Comment on Identifying MP3 files with no MP3 tag
Download Code
Re: Identifying MP3 files with no MP3 tag
by edebill (Scribe) on Jan 02, 2002 at 07:32 UTC

    I've been using a handy little utility called "mp3cddb" and it's companion "mp3cddbtag" to look up mp3's in the cddb database and tag them appropriately. Works quite well. And it's a perl script. :-)

    It might just make the perfect post-processing step after running your script. You can find it at http://k2.jozsef.kando.hu/~drewie/mp3cddb/

Re: Identifying MP3 files with no MP3 tag
by Rich36 (Chaplain) on Jan 02, 2002 at 23:52 UTC
    Quick question - Where is this function? my $tag = get_mp3tag($File::Find::name);. Is get_mp3tag() from a module that's not listed or a function that is not listed or am I missing something?
    Rich36
      get_mp3tag is provided by MPEG::MP3Info.

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

Re: Identifying MP3 files with no MP3 tag
by Kickstart (Pilgrim) on Jan 10, 2002 at 01:09 UTC
    Why not just parse the info that the 'file' command gives you?

    An example:

    $ file Tracy\ Chapman\ -\ Fast\ Car\ Live\ Acoustic.mp3 Tracy Chapman - Fast Car Live Acoustic.mp3: MP3, 128 kBits, 44.1 kHz, +JStereo

    And yes, if you are with the RIAA, I DO own the CD. :)

    Kickstart

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://135550]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-12-26 04:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls