LoginSignup
4
4

More than 5 years have passed since last update.

iTunesライブラリファイルを読み込んで再生回数が0回の曲数をカウントする

Last updated at Posted at 2012-03-10

iTunesのライブラリファイル(iTunes Library.xml)を読み込んで、再生回数が0回の曲数をカウントする。

count.pl
#!/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());
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4