Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Clear out missing files in iTunes Apps
I've moved my iTunes library around from machine to machine for about four machines now, and in the process, many files get lost or missing. But iTunes keeps the references to those files around, resulting in the (to me) dreaded circle-exclamation-point icon, and the task of either finding the file or deleting the reference.

So I sat down and worked out this AppleScript...
tell application "iTunes"
  set thePlaylist to library playlist 1
  set musicFiles to the file tracks of thePlaylist
  
  repeat with mf in musicFiles
    --the name of mf as string
    set hasLoc to ""
    if (the location of mf as string 
     is equal to "missing value") then
      try
        set comment of mf to the comment of mf & ""
      on error number errNum
        delete mf
      end try
      
    end if
  end repeat
end tell
The script goes through the entire library looking for file tracks (stream tracks, for example) and first checks to see if the location of the file returns a missing value. If so, it then tries to append an empty string to the comment of the track (some file tracks return an empty value even though they aren't really empty). If that fails, the file is really missing and is deleted from the iTunes library. This is really the only option since iTunes cannot add a missing track to a playlist or alter the metadata for the track.

[robg adds: It should go without saying, but ... this script will delete things from your iTunes library. Hopefully only missing things, but in case something goes wrong, have you backed up lately?]
    •    
  • Currently 2.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[63,921 views]  

Clear out missing files in iTunes | 15 comments | Create New Account
Click here to return to the 'Clear out missing files in iTunes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Clear out missing files in iTunes
Authored by: DougAdams on Mar 15, '07 07:39:54AM
Super Remove Dead Tracks, which does this as well, is the third most downloaded script at my site.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

Clear out missing files in iTunes
Authored by: redmonk on Mar 15, '07 07:45:45AM

Doug,

I went looking on your site for this functionality but did not know what to call it! Thanks!

--Steve (redmonk)



[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: DougAdams on Mar 15, '07 08:04:33AM
(Nice work, btw!) Yeah. It's one of those scripts I gave a funny name to when I originally wrote it, and back when I only had about a dozen scripts posted! Still, the phrase "dead tracks" has been bandied about for a while when referring to tracks whose files are no longer available. I believe Apple's iTunes AppleScripts collection had a similar script as well--I just noticed they no longer make those available.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

Clear out missing files in iTunes
Authored by: neuralstatic on Mar 15, '07 09:34:40AM

SRDT is a staple when you have a big library and can't spend time rescanning from scratch. thanks Doug



[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: marioestrada on Mar 15, '07 11:44:19AM

Is there anyway to do the opposite? Check for files that are on itunes folder but not referenced on the library??

---
mario



[ Reply to This | # ]
Add missing files in iTunes
Authored by: hypert on Mar 15, '07 02:12:16PM

Just drag-and-drop your Music folder onto iTunes once in a while. It can take a while, but I've never had anything bad happen by doing it. And all tracks missing from iTunes will show back up.

Oh, this might reset the Date Added property on every track, though, so it could throw off any Smart Playlists you have using that criteria.



[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: loren_ryter on Mar 16, '07 01:24:10PM
Doug's site is the place to go for iTunes scripts.

http://www.dougscripts.com/itunes/

This one would generate a text file than you could use to add them manually or make a quick script to loop through them:

http://dougscripts.com/itunes/scripts/scripts07.php?page=1#listfolderfilesnotadded

[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: loren_ryter on Mar 16, '07 01:26:44PM
In addition to SRDT, iDupe handles dead track removal as well as optional attempts to resture them:

http://www.woodenbrain.com

[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: squawbrah on Mar 23, '07 04:35:21AM

Here's a quick and dirty way of finding all dead tunes:

1. Create a new, empty playlist, e.g. "Foo"
2. Select All in the Library and drag every track to Foo.
    (Dragging causes all dead tracks to exclamate themselves and not be transferred to the new playlist.)
3. Create a smart playlist, set the criterium to Playlist is not Foo.

Presto digito, all the dead tracks are in "Not Foo" where you can delete them.



[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: kupietz on Jul 21, '07 03:53:38PM

Doesn't work for me - will not let me drag all my mp3s to a playlist, either in the left hand column or open in a new window. They must have "fixed" this. It's good, you know, I like for simple tasks to be as difficult and time consuming as possible. Kudos to iTunes for being so exceptional at that.



[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: idf on Jan 09, '09 11:57:56AM

Well this one works fine for me.

After an external firewire HDD started to die on me, I was able to rescue most of my iTunes library off it, with the exception of 85 files.

Now I can easily identify them and re-rip the CDs.

Thanks



[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: dcottle on May 06, '07 07:29:05AM

This seems a little dangerous, but I've done it several times: Select all tracks, delete, but check the "keep" option. Drag entire iTunes folder back into iTunes. It only restores those that actually exist.



[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: kupietz on Jul 21, '07 10:06:49AM

This will erase the info that lives only in your files' iTunes Library (ratings, etc.)



[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: kupietz on Jul 21, '07 03:56:53PM

I thought of something... another thing you can do is simply select all your mp3s, do a "get info", and pick an unused tag - in my case, "BPM" - and set it to a custom value like '723' across all your files. Then show that column & sort by it, and all the missing tracks will be grouped together because their tags didn't update. Then you can just selec & delete.



[ Reply to This | # ]
Clear out missing files in iTunes
Authored by: Rolf Raikou on Feb 16, '09 02:47:43AM

Quicker than filling out text in a field, this is what I tried, though mind you, I never rate my music. This might not work for those that rate their music.

The exclamations only showed up on a few seemingly random songs. out of 100GB this was a lot to sort.

I dragged my music folder into itunes, automatically finding the missing songs.

At this point I had duplicates, the old ones with exclamations, and the new ones that worked just fine.

Go click on "show duplicates" then give all your duplicates a rating. (this goes WAY faster than changing text in a field)

ONLY your duplicate files will be affected, and all you have to do now is sort by rating.

The exclamations will be without a rating, and the good files you want to keep will have whatever rating you set.

Remove the afflicted files and you're good to go.

Took me ten minutes TOPS doing it this way.



[ Reply to This | # ]