26

When cleaning up my disk I deleted a couple of files from my music collection which iTunes was managing. Now when I try to sync a device I get an error message that it can't sync these files because they don't exist. The problem is that I can't find these files in iTunes any more to delete them. They don't appear when I search for appropriate terms. So, my question is how do I find them, and is iTunes hiding them from me in some "smart" way?

4 Answers 4

4

For adding functions to iTunes you should look at Doug;s Applescripts. There is a script to remove dead tracks.

0
20

I've found the easiest most reliable solution yet! No scripts, no loss of playcounts/ratings etc.

  1. Create a new playlist, say temp.
  2. Select all your the tracks you want to deal with and drag and drop them to the playlist. The new playlist will only contain valid tracks. All invalid tracks will be marked with the exclamation mark.
  3. Switch to the playlist and select all the tracks, then right-click and Uncheck Selection
  4. Switch back to Music and sort by the checkmark - now all the invalid tracks are grouped together!
  5. Select them all and delete!

You can then go and Check the songs again to make sure they get synced to devices.

7
  • 1
    Being forced to endure iTunes in Windows because of certain devices, this feels like the easiest option to me. Mar 4, 2012 at 18:51
  • Unfortunately as of iTunes 11 this appears to no longer work. Invalid tracks are now added to the playlist. Feb 14, 2013 at 19:22
  • Still works fine for me. I've just deleted some tracks in an album, then selected all the songs in the album and dragged them to a temp playlist. As soon as I started dragging, the deleted items showed exclamation marks and after dropping to the temp playlist, only the valid tracks appear in the playlist.
    – nevster
    Feb 18, 2013 at 12:08
  • Hrm. Just tried it again and it seems to be working. Either a recent update to iTunes 11 fixed this or I missed something before. Mar 5, 2013 at 20:32
  • "Brilliantly Simple" ?? I'd say a simple menu item like 'Clean up library' would deserve more to be called 'brilliantly simple'... Still, I agree, this seems the most sane way to do it. Dec 4, 2014 at 20:03
4

A roundabout way is longer, but doesn't need any scripts.

  1. Export your library to the desktop as an xml
  2. quit iTunes and move these files to the desktop / trash

    • iTunes Music Library.xml
    • iTunes Library.itl
    • iTunes Library Extras.itdb
    • iTunes Library Genius.itdb
  3. Start iTunes - it will look "empty" but all your programs and music are still around

  4. Drag the iTunes Media folder into your iTunes window - Library on the top left - drop the folder over Music or the other categories and iTunes will re-add them to the database, but only the files that exist still on the drive will be added
  5. Import the saved library.xml file - this will add back all the ratings, playlists, and songs that no longer exist will be cleaned out of the playlists
2
  • 1
    This is the only thing that worked well for me. Thanks!
    – odedia
    Nov 10, 2020 at 12:36
  • 1
    The benefit is these periodic export / backups of my XML file have saved me when Apple burps and I lose some playlists or want to remember what was in my spring 2016 playlist a couple years after I deleted it. @odedia I appreciate the confirmation it worked for you.
    – bmike
    Nov 10, 2020 at 17:27
4

The script from Doug's AppleScripts for iTunes is now part of a commercial application, but a version from 2011 can still be downloaded for free here.

Here is a simpler script that should do more or less the same thing:

tell application "iTunes"
    repeat with t in (get file tracks of library playlist 1)
        if location of t is missing value then delete t
    end repeat
end tell
2
  • This one removes every second file that is not present on every run. The reason it probably worked for you with five runs is that 2^5 is already 32 so after 5 runs, only 1/32th of your missing files would still be there
    – 0x89
    Jun 17, 2013 at 7:01
  • 1
    @0x89 You're right, it was looping through references like item 1035 of every file track of library playlist 1 of application "iTunes". I edited the script to add an explicit get.
    – Lri
    Jun 17, 2013 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .