#!/usr/bin/perl # For adding the date use Time::Local; $File = "iTunes Music Library.xml"; $SongNumber = 0; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); open (FILE, "$File"); print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "

COMPLETE SONG LIST<\h3>\n"; printf "Compiled %02d-%4d

\n", $mon+1, $year+1900; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; while () { chomp; #Note that Name, Artist, Albuma nd Genre must be in the exact order as they are in the iTunes XML file if (/>NameName<\/key>//; $prep = s/<\/string>//; $Name = "$_"; chomp $Name; } elsif (/>ArtistArtist<\/key>//; $prep = s/<\/string>//; $Artist = "$_"; chomp $Artist; } elsif (/>AlbumAlbum<\/key>//; $prep = s/<\/string>//; $Album = "$_"; chomp $Album; $SongNumber++; } elsif (/>GenreGenre<\/key>//; $prep = s/<\/string>//; $Genre = "$_"; chomp $Genre; #Once Genre has been captured, we filter out the audiobooks, podcasts and radio stations if (($Genre eq 'Audiobook') || ($Genre eq 'Podcast') || ($Genre eq 'Radio')){ $SongNumber--; } #Here we print out the song info, as part of the genre loop else { print "\n"; } } } print "\n"; print "Total number of songs: $SongNumber <\/b>\n"; print "\n"; print "\n"; close FILE;
SONG:ARTIST:ALBUM:
"; print "$Name"; print ""; print "$Artist"; print ""; print "$Album"; print "