filtering itunes library items by file location

3 answers and unfortunately no solution yet.

The Problem

I've got way more than 1000 duplicated items in my iTunes Library pointing to a non-existant place (the "where" under "get info" window), along with other duplicated items and other MIAs (Missing In Action).

Is there any simple way to just delete all of them and only them? From the library, of course.

By that I mean some MIAs are pointing to /Volumes while some are pointing to .../music/Music/... or just .../music/.... I want to delete all pointing to /Volumes as to later I'll recover the rest. Check the image below.

Some Background

I tried searching for a specific key word on the path and creating smart play list, but with no result.

Being able to just sort all library by path would be a perfect solution! I believe old iTunes could do that. PowerTunes can do it (sort by path) but I can't do anything with its list. I would also welcome any program able to handle this, then import and properly export back the iTunes library.

PowerTunes showing Path Column and duplicated items

Since this seems to just not be clear enough...

AppleScript doesn't work

That's because AppleScript just can't gather the missing info anywhere in iTunes Library. Maybe we could use AppleScript by opening the XML file, but that's a whole nother issue.

Here's a quote from my conversation with Doug the man himself Adams last december:

I don't think you do understand. There is no way to get the path to the file of a dead track because iTunes has "forgotten" it. That is, by definition, what a dead track is.

Doug

On Dec 21, 2010, at 7:08 AM, Caue Rego wrote:

yes I understand that and have seem the script. but I'm not looking for the file. just the old broken path reference to it.

Sent from my iPhone

On 21/12/2010, at 10:00, Doug Adams wrote:

You cannot locate missing files of dead tracks because, by definition, a dead track is one that doesn't have any file information. If you look at "Super Remove Dead Tracks", you will notice it looks for tracks that have "missing value" for the location property.


Solution 1:

I would recommend trying out Doug's Applescripts:

http://dougscripts.com/itunes/


There are many free Applescripts that are more tailor-made for a specific issue rather than a one-size-fits all solution such as FixTunes or PowerTunes. I have used the Super Remove Dead Tracks v2 before and it worked well.


There are also scripts for:

  • Removing duplicates (Search for Super Remove Duplicates)
  • Playing a random song from a random playlist, and other things iTunes should do
  • Better mass tag editing
  • Script to send contents of clipboard to iTunes as current song's lyrics (WAY cool): *
  • And also "ScriptPal", a floating palette plugin that allows you to manage and run scripts much more easily than before.

Oh yea, all of these are also free and adjustable yourself (just learn AppleScript, it's THAT easy lol) unlike a paid program which can't be adjusted.

Solution 2:

Did the non-existant path exist at one time? That can help you figure out why this happened. What I would do in that case is move the iTunes Library heirarchy you do have back to that location and work from there. If you don't have one or it just doesn't exist, here's a pretty foolproof method of doing what you want, though it's not all that pretty:

Go to File->Library->Organize Library... and consolidate your library. Delete/Archive your existing Library data file (the stuff in ~/Music/iTunes/ that sits next to the iTunes Music folder) or generate a new library for iTunes by launching it while holding Option.

Drop the iTunes Music folder mentioned above onto the now blank iTunes app. It'll import only the songs you actually have data for.

Edit:

Okay, you asked for it :-)
Hack the iTunes Music Library.xml file. I'm not going to test this myself, but you should be able to be successful.

  1. Make lots of backups and quit iTunes.
  2. Get a good plaintext editor and use it to edit ~/Music/iTunes/iTunes Music Library.xml
  3. Use some sneaky find/replace/RegEx and delete every <key><dict> pair that contains the nonexistant path in the Location key string.
  4. I read somewhere that the iTunes Library file is reconstructed from iTunes Music Library.xml if it's found to be corrupt. If the changes you made to the XML haven't taken effect by now, you may need to delete ~/Music/iTunes/iTunes Library, or just open it up in the text editor and mess with it a little. Might take some experimenting, but report back when you find out what works!

Solution 3:

Use PowerTunes to fix your library.

alt text

Solution 4:

Some misconceptions:

The XML file is not used by iTunes at all. It is created for the benefit of third-parties.

You cannot locate the file path of a dead track because it is no longer in the iTunes database, which means it will not be in the XML either.

There is no extant file path of a dead track anywhere. You might be able to use the Artist and Album name of a track to search the iTunes Media folder for it. For example, the file for the track "In the AIr Tonight" on the Phil Collins' album Face Value might be located at iTunes Media/Music/Phil Collins/Face Value/In the Air Tonight.ext, but there is no absolute certainty that it is.