Skip to content

Instantly share code, notes, and snippets.

@redtower
Created March 10, 2012 08:37
Show Gist options
  • Save redtower/2010864 to your computer and use it in GitHub Desktop.
Save redtower/2010864 to your computer and use it in GitHub Desktop.
iTunesライブラリファイルを読み込んで再生回数が0回の曲数をカウントする ref: http://qiita.com/items/3107
#!/usr/bin/env perl
use strict;
use warnings;
use Mac::iTunes::Library;
use Mac::iTunes::Library::XML;
my $library = Mac::iTunes::Library::XML->parse( 'iTunes Library.xml' );
my $count=0;
my %items = $library->items();
while (my ($artist, $artistSongs) = each %items) {
while (my ($songName, $artistSongItems) = each %$artistSongs) {
foreach my $song (@$artistSongItems) {
if (!defined($song->playCount())) {
$count++;
}
}
}
}
printf("%5d / %5d\n", $count, $library->num());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment