iTunes Cleaner

| | Comments (0)
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.

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 }}'

OK, here it is more readable:

use Mac::Glue;
 
$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)

use.perl.org

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on May 26, 2003 9:21 AM.

Hints was the previous entry in this site.

Arrogant, Ignorant, Both ... ? is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.