September 19

iTunes – List Dead Tracks – To File

this script will list all dead tracks in your iTunes library in a file called “DeadTracks.txt”

/* by Calen Fretts */ var ITTrackKindFile = 1; var iTunesApp = WScript.CreateObject("iTunes.Application"); var tracks = iTunesApp.LibraryPlaylist.Tracks; var numTracks = tracks.Count; var matchTracks = 0; var fso = new ActiveXObject("Scripting.FileSystemObject"); var FILE_NAME = "DeadTracks.txt"; var myFile = fso.CreateTextFile(FILE_NAME); WScript.Echo("Finding dead tracks..."); while (numTracks != 0) { var currTrack = tracks.Item(numTracks); // is this a track? if (currTrack.Kind == ITTrackKindFile) { if (currTrack.Location == "") { myFile.WriteLine("" + currTrack.Artist + " - " + currTrack.Album + " - " + currTrack.TrackNumber + " - " + currTrack.Name + ""); matchTracks++; } } numTracks--; } myFile.Close(); if (matchTracks == 0) { WScript.Echo("No dead tracks."); myFile = fso.GetFile(FILE_NAME); myFile.Delete(); } else { WScript.Echo("Found " + matchTracks + " dead tracks - see the following file: " + FILE_NAME); }

copy the code into a new text file, and rename its extension to “.js”. if you post this code anywhere else, please be sure to give me credit by linking back to this site. got questions or improvements? leave a comment!


Tags: , , ,
Copyright © 2014. All rights reserved.

Posted September 19, 2008 by calenfretts in category "geek", "iTunes