[Skip To Content]


# Missing songs in iTunes

This week, I was moving my iTunes library off an external HDD to a network share and somehow managed to completely badger it up. All the songs were still showing in iTunes and they were all on disk in their original places, but something had happened to their location in the iTunes database and were showing with an exclamation, indicating iTunes couldn’t find them.

After fixing these by trying to play the songs and manually locating them on disk, I was still finding songs which weren’t indicated by iTunes as missing, but actually were. So, I quickly wrote the below script to list all the broken tracks in my library. Unfortunately, there doesn’t seem a way to set the location automatically.

So yeah, I don’t know if this will be useful to anyone else, but here is the code …

  1. require "rubygems"
  2. require "rbosa"
  3. library_playlist = OSA.app( "iTunes" ).sources.find{ |s| s.name == "Library" }.library_playlists.first
  4. # Songs which are broken have a location of 'nil', but still have the
  5. # rest of the information.
  6. library_playlist.file_tracks.reject{ |t| t.location }.each do |track|
  7. puts '"%s" by %s, off "%s"' % [ track.name, track.artist, track.album ]
  8. end

More about this site...

Last Week’s Top 5 Albums (More »)

  1. Pretty. Odd.Panic at the Disco
  2. BoxerThe National
  3. Du och jag dödenKent
  4. Lovesongs For UnderdogsTanya Donelly
  5. You Are the QuarryMorrissey