Skip to content

Instantly share code, notes, and snippets.

@DomiR
Forked from anonymous/gist:3267597
Last active August 29, 2015 14:20
Show Gist options
  • Save DomiR/fe0ae4fced59f314796d to your computer and use it in GitHub Desktop.
Save DomiR/fe0ae4fced59f314796d to your computer and use it in GitHub Desktop.
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.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment