Main Page/Stuff/Ripping Karaoke CDs/write mp3 songlist.pl
From phurvitz
< Main Page | Stuff | Ripping Karaoke CDs
<source lang=perl>
- ! /usr/bin/perl
use MP3::Tag;
- list all files
chdir "c:/program files/karafun/songs"; @mp3files = `ls *.mp3`;
- print @mp3files;
- a list of titles & artists
@titleartists = (); @artisttitles = ();
for $f (@mp3files) {
chomp $f; $mp3 = MP3::Tag->new($f); ($title, $artist, $artist, $album, $comment, $year, $genre) = $mp3->autoinfo(); $artisttitle = "$artist\t$title\t$album"; push (@artisttitles, $artisttitle); $titleartist = "$title\t$artist\t$album"; push (@titleartists, $titleartist);
}
open (LIST, ">c:/program files/karafun/songs/songlist.txt"); @sorted = sort { lc($a) cmp lc($b) } @titleartists; print LIST "Title\tArtist\tAlbum\n"; print LIST "=====================\n"; for $t (@sorted) {
print LIST "$t\n";
}
print LIST "\n\n\n\n";
@sorted = sort { lc($a) cmp lc($b) } @artisttitles; print LIST "Artist\tTitle\tAlbum\n"; print LIST "=====================\n"; for $t (@sorted) {
print LIST "$t\n";
}
close LIST; </source>