Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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 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" } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://185743]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2018-02-22 17:44 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (297 votes). Check out past polls.