#!/usr/bin/perl -w use strict; use mp3::ID3v1Tag; sub Renamer { foreach (@_) { my($artist, $title) = (split '-'); ($artist, $title) = &splitter($artist, $title); rename "$_", "$artist - ${title}(1).mp3" or die "cannot rename to $_ to ${title}.mp3: $!"; } print "finished Renaming.\n"; } sub Tagger { foreach (@_) { my($artist, $title) = (split '-'); ($artist, $title) = &splitter($artist, $title) my $mp3_file = new MP3::ID3v1Tag($_); $mp3_file->set_title($title) or die "cannot set title: $!"; $mp3_file->set_artist($artist) or die "cannot set title: $!"; $mp3_file->save() or die "Cannot save changes: $!"; } print "finished ID3 Tagging.\n"; } sub splitter { substr($_[0], -1, 1, ''); print "\$_[0] = ${_[0]}END\n"; substr($_[1], 0,1, ''); print "\$_[1] = BEGIN$_[1]\n"; substr($_[1], -4, 4, '') if substr($_[1], -4, 4) eq '.mp3'; return ($_[0], $_[1]); } print "MASS ID3 Tagger and Renamer by Incst. Input a directory or type exit to exit.\n"; while (1) { chomp(my $dir = ); if ($dir eq exit) { last; } else { chdir $dir or die "Cannot change to specified directory: $!"; my @MP3_files = <*.mp3>; &Tagger(@MP3_files); &Renamer(@MP3_files); }