filtering itunes library items by file location

2

1

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.

cregox

Posted 2010-12-20T03:38:57.560

Reputation: 5 119

So Doug says the same thing I did in a comment to Brandon's answer ;) – Daniel Beck – 2011-01-12T14:04:31.687

@Daniel yes. He could barely understand my question because it just sounded too absurd to his subconscience, I think. – cregox – 2011-01-12T14:16:49.330

@Daniel btw... how you noticed my edit so quickly? – cregox – 2011-01-12T14:31:52.010

Editing questions and answers moves the topic to the top of the front page. – Daniel Beck – 2011-01-12T14:32:45.427

@Daniel that far I knew, that's why I added the comment on the top. So was it just a coincidence or you actually keep refreshing that page and looking at it? :o – cregox – 2011-01-12T17:57:10.647

1

A bit of both. Click me!

– Daniel Beck – 2011-01-12T18:00:47.740

@Daniel wooot, nice! I'd never be able to do that. :P – cregox – 2011-01-14T10:33:08.090

I'm not quite sure that's the best use of anyone's free time though ;-) – Daniel Beck – 2011-01-14T10:34:39.320

@Daniel that's exactly what I meant. How about kitesurfing? Aah... I wish I could.

– cregox – 2011-01-14T10:43:22.477

Answers

6

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.

Brandon

Posted 2010-12-20T03:38:57.560

Reputation: 314

Edited your post to link to the dead tracks script. The last paragraph didn't make sense in the context of this topic and after my edit, so I removed it. Hope I didn't make a mistake with that. – Daniel Beck – 2010-12-20T09:57:45.300

Yes, got all Doug's scripts and few more. Thanks for pointing them, they are great! Just not for this task. Maybe I should learn how to script myself. – cregox – 2010-12-20T12:41:30.330

Would any of you, Brandon or @Daniel, happen to know applescript enough to tell me how I can retrieve that location info? I do know it's surely stored somewhere as I mentioned on the question but using file track's location brings only missing value. – cregox – 2010-12-20T18:41:06.260

@Cawas I can only guess (and reproduce the issue) that it's missing value because the path does not exist, and the type is alias, which probably requires a path to exist. Even converting to POSIX path does not work. – Daniel Beck – 2010-12-20T18:51:11.167

I've never found anything that was simple or intuitive in Applescript. There is a Python wrapper for OSA called AppScript, but I haven't used it much. That being said, I have spent countless hours trying to make them work. Get the program called "Script Debugger 4.5". Without that, it's like programming blind and deaf. This program has a SUPER great 'Dictionary' feature AND an 'Explore' feature that is unmatchable in showing how all that crap actually fits together. It can browse currently running programs and show you the current values, then put that into a script. Indispensable. – Brandon – 2010-12-21T07:55:10.130

"@Brandon" ( quoted to indicate I didn't need to use @ here, but I'm using it to point you should have ;) ) thanks for that... only problem is I don't have $200 to spend on such a thing to use just once or maybe twice in a year. I'm trying it for 20 days anyway, but it'd be really nice if you just told me about the specific question and said "I used this ". You see, I'm almost giving up on using applescript for this because I highly doubt it can retrieve that value trough iTunes. I probably should have gone with plan B (from NReilingh) sooner. out to give a shot and report back now. ;) – cregox – 2010-12-21T14:40:21.333

Yes, indeed that's just overkill to me. I also tried alternate free tools in there, but I'm just not there yet. Sorry Brandon. And thanks! - moving now to plan B – cregox – 2010-12-21T15:15:58.323

1To people who are voting this answer up, you really should pay more attention and read before voting. Or at least do what I do and keep on the "dynamic reading" but also voting the other answers up as to not give weight for just 1 uncertainty. :D – cregox – 2010-12-21T15:18:00.943

Just an addition: back then, weeks ago, I actually contacted Doug asking about grabbing the file location from dead tracks. He could barely understand what I meant because it was such an absurd question to him as "just impossible". So, applescript just isn't an answer to this question. – cregox – 2011-01-08T03:35:12.560

1

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!

NReilingh

Posted 2010-12-20T03:38:57.560

Reputation: 5 539

Yes, the path exists and it's actually an external HD that I use for backup. I tried consolidating / "reorganizing", but didn't work. Everything else you suggested seem to potentially delete all my iTunes metadata, specially the ranks. I really wish to avoid doing that. Any more ideas? :P – cregox – 2010-12-20T04:10:33.477

about your edit, I'll try that as plan B. thanks. :) – cregox – 2010-12-20T05:33:54.853

I actually tried using plan B, but it ain't that simple. I'd need a RegEx to copy every <key><dict> into some field iTunes could sort. But all regular fields already have data! Plus, such RegEx is non trivial. – cregox – 2011-01-09T02:37:10.377

Just as a reference, here's more on plan B: http://www.xml.com/pub/a/2004/11/03/itunes.html

– cregox – 2011-01-14T10:47:04.063

1

Use PowerTunes to fix your library.

alt text

Daniel Beck

Posted 2010-12-20T03:38:57.560

Reputation: 98 421

sounds amazing! trying it out right now... – cregox – 2010-12-20T05:33:20.767

@Cawas Did it work? I don't understand the edit to your question. – Daniel Beck – 2010-12-20T06:54:29.187

Sorry for not giving you a notification, Daniel. Didn't want to bloat every answer with my un-ending comments, but I guess it's too late now anyway. I'm still trying to make it work, but so far it didn't. I could find a column "path" I could add to the main window, and order by it - it is all I needed (and I'm pretty sure iTunes previous than 10 had this)... But then I can't use that to delete them! – cregox – 2010-12-20T12:43:38.220

@Cawas So you really need the path? I tried it a few weeks myself on a relative's machine and there is just no way to access the path in iTunes itself AFAIK. This answer is more about how you can fix/remove the tracks -- I guess I didn't understand your question then (perhaps you can edit to clarify?). And don't mind the comment thread -- I seem to provoke them ;-)

– Daniel Beck – 2010-12-20T12:53:27.313

Well, I actually do appreciate every other answer here, because this is [not the only thing I need to organize in my itunes][http://superuser.com/questions/224040/organizing-my-music-and-my-itunes] (how you do links in comments?). But, yeah, for this question the path is all i need and PowerTunes made me realize / remember of that discontinued option. Btw - 26 comments! Well, you did get Arjan there with you, which explains a lot. ;P – cregox – 2010-12-20T13:10:18.260

@Cawas Links in comments are the same, but their format is always [label] (URL). – Daniel Beck – 2010-12-20T13:16:21.060

1

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.

Doug Adams

Posted 2010-12-20T03:38:57.560

Reputation: 11

Sup crazy Doug?! So, what you're saying here is that there is just no way? :-o – cregox – 2012-04-10T10:51:19.083

0

Perhaps I don't understand the full scope of the question.... And I'm a Windows user.

Inside of iTunes: Select all the files, Get info on the lot of them.
Every file that can't be found will have an exclamation mark in the leftmost column (grey circle, white mark)

See if these lost files have any common searchable denominator - for me it usually is a date (added, modified), or Artist. Then search and destroy on that. Yes this could involve a lot of selecting of individual files but you could be listening to music at the same time.

Before you delete any files though, you should be sure that the MIAs weren't on an external or old drive. Try to connect to any network, external etc. storage. Did your roommate stop sharing a folder?

For duplicates - I haven't found a fail safe way of selecting the "right" files to delete. iTunes doesn't do a good job of pairing files (duplicates). I'd be pleased to hear of a good way to attack this problem

Anne L

Posted 2010-12-20T03:38:57.560

Reputation: 41