Man, don't you just love having to use iTunes to manage and sync your iPods, iTouches, iPhones and iEtc? And isn't it great when you want to add new tunes to your library, but not 'consolidate' that library into your iTunes folder (thus doubling your disk usage)? Ooh! And if you move stuff around, you end up with a bunch of dead tracks? Well, here's a little piece of VBScript that will remove all the dead tracks in iTunes for windows. For every track it finds in the library that the file is no longer there -- BLAMMO - removed from the library.
- Open iTunes and go to your MUSIC library. Press CTRL-A to select all tunes. Don't do anything else.
- Save the little piece of code below to a file on your disk, say "c:\removedead.vbs"
- run this command using the Start button and the run option: cscript c:\removedead.vbs
- Wait. Patiently. Depending on the number of tracks you have in your library, it could take a while.
- When done, it will report the number of tracks removed from the library.
Code snippet:
' RemoveDead.vbs
ITTrackKindFile = 1
deletedTracks = 0
set iTunesApp = WScript.CreateObject("iTunes.Application")
set mainLibrary = iTunesApp.LibraryPlaylist
set tracks = mainLibrary.Tracks
for each currTrack in tracks
' is this a file track?
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
next
WScript.Echo "Removed " & deletedTracks & " dead track(s)."
' RemoveDead.vbs
No comments:
Post a Comment