iTunes has a tendency to retain entries in the library to nonexistent files. Here is a little script to tell you which entries in your library are orphans (similar to the duplicate script I posted earlier, but a bit simpler, and on one line because that is how I did it). It optionally deletes them.
OK, here it is more readable:
$d = 0;
$i = new Mac::Glue "iTunes";
for $t ($i->obj(tracks => library_playlist => 1)->get) {
if ($t->prop("location")->get eq "msng") { # 'missing value'
print join " - ", map { $t->prop($_)->get } qw(name artist album);
$t->delete if $d
}
}
It found three tracks off Primus' Sailing the Seas of Cheese album were disappeared. The files are not there. I have no idea why.
Now Playing: Tommy The Cat - Primus (Sailing The Seas Of Cheese)
Re:sweet
rexroof on 2003-06-19T16:55:32
shit, I guess pre tags don't work.
[mogu:~] rex% perl -MMac::Glue -le '$d = 0; $i = new Mac::Glue "iTunes"; for $t ($i->obj(tracks => library_playlist => 1)->get) { if ($t->prop("location")->get eq "msng") { print join " - ", map { $t->prop($_)->get } qw(name artist album); $t->delete if $d }}'
No application glue for 'iTunes' found in '/Library/Perl/Mac/Glue/glues' at -e line 1
[mogu:~] rex%
Re:sweet
pudge on 2003-06-19T21:57:22
You need to create one (you read the Mac::Glue documentation*, right?;-). You may need to use sudo, or otherwise run as root, as the glue is by default saved into your perl's sitelib path.% gluemac/Applications/iTunes.app
That will create the necessary glue for whatever app you wish to script with Mac::Glue. Use gluedoc iTunes to read the documentation for that created glue file.
Also, <ECODE> tags are the way to do code on use.perl.org (and many other Slash sites, like Slashdot).
* The docs are still a bit Mac OS-centric, but there are some Mac OS X notes in them, and the README also discusses some Mac OS X-specific bits.Re:sweet
rexroof on 2003-06-20T20:24:55
thanks for not slamming me;) works great.
hope you're having fun unpacking.