RemoveDeadTracks.js


Article Image
Tags:

Added On: 5th Jan 08

Links: [download]

This script will run through your iTunes library and delete all those pesky little exclaimation marked “dead” tracks, which iTunes cannot find on your computer.

Sometimes another program will move the files, or iTunes will apparently just “forget” where they are! Running this download will remove all these unlinked tracks from the list.


var ITTrackKindFile = 1;
var iTunesApp = WScript.CreateObject("iTunes.Application");
var deletedTracks = 0;
var mainLibrary = iTunesApp.LibraryPlaylist;
var tracks = mainLibrary.Tracks;
var numTracks = tracks.Count;
var i;
while (numTracks != 0)
{
var currTrack = tracks.Item(numTracks);
// is this a file track?
if (currTrack.Kind == ITTrackKindFile)
{
// yes, does it have an empty location?
if (currTrack.Location == "")
{
// yes, delete it
currTrack.Delete();
deletedTracks++;
}
}
numTracks--;
}
if (deletedTracks > 0)
{
if (deletedTracks == 1)
{
WScript.Echo("Removed 1 dead track.");
}
else
{
WScript.Echo("Removed " + deletedTracks + " dead tracks.");
}
}
else
{
WScript.Echo("No dead tracks were found.");
}

Related Posts:

This post has been read 1,035 times.

No Comments

Leave a comment