#!/usr/bin/perl -w # 2001.02.18 altblue ## use strict; use MP3::Info; use File::Find; my $directory = $ARGV[0] ? $ARGV[0] : '.'; File::Find::finddepth({wanted => \&process_file}, $directory); exit; sub process_file { my $file = $_; my $tag = get_mp3tag($file) or return undef; # my $track = ''; m/^(\d\d)/ and $track = $1; # my $new = ($track ? "$track." : '') . "$$tag{ARTIST} - $$tag{TITLE}.mp3"; my $new = "$tag->{ARTIST} - $tag->{TITLE}.mp3"; if (exists $tag->{TRACKNUM} && $tag->{TRACKNUM} =~ /^\d+$/) { $new = sprintf "%02d.%s", $tag->{TRACKNUM}, $new; } $new = lc $new; printf "%40s -> %s\n", $file, $new; rename $file, $new; }