Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: title/artist info

by dree (Monsignor)
on Jul 27, 2002 at 12:19 UTC ( #185743=note: print w/ replies, xml ) Need Help??


in reply to title/artist info

You can also use tagged.

Here a simple mp3 command line renamer that use File::Find to traverse the given directory structure:

use strict; use File::Find; use MP3::Tag; my $dir=$ARGV[0]; die "use mp3ren.pl directory_name" if (!$dir); find (\&wanted, "$dir"); sub wanted { if (&match("$File::Find::name")) { &rename_MP3($File::Find::name); } } sub match { my $filename=$_[0]; if (-d $filename) { return 0; } my $mp3 = MP3::Tag->new($filename); if (defined $mp3) { $mp3->get_tags; if (exists $mp3->{ID3v1}) { return 1; } else { print "$filename is not mp3 or no ID3v1 tag\n"; return 0; } } } sub rename_MP3 { my $fullname_mp3=$_[0]; my $mp3 = MP3::Tag->new($fullname_mp3); my $new_mp3_name; $mp3->get_tags; my $song=$mp3->{ID3v1}->song; my $artist=$mp3->{ID3v1}->artist; if ($artist && $song) { $new_mp3_name="$artist--$song"; } elsif ($song) { $new_mp3_name="$song"; } elsif ($artist) { $new_mp3_name="$artist--untitled"; } else { $new_mp3_name=""; } if ($new_mp3_name) { $new_mp3_name=~s#[\\|\?|\*|\||\:|"|<|>|/]+##g; $new_mp3_name.=".mp3"; $new_mp3_name="$File::Find::dir/$new_mp3_name"; if ($fullname_mp3 eq $new_mp3_name) { print "Error renaming $fullname_mp3 to $new_mp3_name: same nam +e\n" } elsif (!rename("$fullname_mp3","$new_mp3_name")) { print "Error renaming $fullname_mp3 to $new_mp3_name: $!\n" } else { print "Renamed $fullname_mp3 to $new_mp3_name\n" } } else { print "Error renaming $fullname_mp3: no ID3v1 tag\n" } }


Comment on Re: title/artist info
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-08-20 22:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (124 votes), past polls