ITunes: Deleting Dead Tracks From ITunes
There are some key differences between these apps.
1. Media Player gets properties off of the actual file or folder. iTunes saves some information in its database and some of it is in the file.
2. Media Player puts an album art file for album art, where iTunes puts the album art in a Album Art folder, then under some convoluted database that doesn't match back to the album. Neither of the players will look for the other, so converting is not fun.
3. iTunes copies files when organizing its library, iTunes copies creating duplicate files. Media Center Moves the files underneath my consolidated library.
4. iTunes doesn't know if the file system deleted a file or a new file exists in the library. Media Player continually looks for new music, pictures and movies.
This is why I found the following code, in the Apple SDK, that will delete dead tracks from you iTunes library.
dim ITTrackKindFile
ITTrackKindFile = 1
dim iTunesApp
set iTunesApp = WScript.CreateObject("iTunes.Application")
dim deletedTracks
deletedTracks = 0
dim mainLibrary
set mainLibrary = iTunesApp.LibraryPlaylist
dim tracks
set tracks = mainLibrary.Tracks
dim numTracks
numTracks = tracks.Count
dim i
while (numTracks <> 0)
dim currTrack
set currTrack = tracks(numTracks)
if ( currTrack.Kind = ITTrackKindFile) then
' yes, does it have an empty location?
if (currTrack.Location = "") then
' yes, delete it
currTrack.Delete()
deletedTracks = deletedTracks + 1
end if
end if
numTracks = numTracks - 1
wend
if (deletedTracks > 0) then
if (deletedTracks = 1) then
WScript.Echo("Removed 1 dead track.")
else
WScript.Echo("Removed " & deletedTracks & " dead tracks." )
end if
else
WScript.Echo("No dead tracks were found.")
end if