Editing songs in iTunes 11.0.2

  1. check if you have relocated songs.
  2. check if your files can be rewritten.

I use self-written python program to remove stale content.

import win32com.client
itunes= win32com.client.Dispatch("iTunes.Application")
ITTrackKindFile=1
mainLibrary = itunes.LibraryPlaylist
tracks = mainLibrary.Tracks
numTracks = tracks.Count
deletedTracks=0
batch_size = 90 
deleted = []
while True:
  while numTracks  !=0:
   currTrack=tracks.Item(numTracks)
   if currTrack.Kind == ITTrackKindFile:
       if currTrack.Location == "":
         deleted.append(currTrack)
   numTracks-=1
   for track in deleted:
      track.Delete()
      deletedTracks+=1
   del deleted[:] # free memory and close handles
   if not numTracks:
     break

if deletedTracks > 0:
if deletedTracks == 1:
  print "Removed 1 dead track."
else:
  print "Removed " + str(deletedTracks) + " dead tracks."
else:
  print "No dead tracks were found."