iTunes won't restore all files from iTunes Music Library.xml

Discussion in 'Mac Apps and Mac App Store' started by plab, Nov 14, 2008.

  1. macrumors newbie

    Nov 14, 2008
    I had to move around my files recently so needed to change the location iTunes looked for them. I ran across a hack whereby you edit the iTunes Music Library.xml file and then intentionally corrupt the iTunes Library.itl file so that it reimports the next time you restart iTunes (I'm sure many of you may already be familiar with this hack).

    It almost works.

    Problem is that it doesn't import all my files. I have over 10000 files but it only imports 6445 of them. I noticed that the original xml filesize is 16MB. After importing, it gets chopped down to 10MB. What the heck is happening here?
  2. thread starter macrumors newbie

    Nov 14, 2008
    The plot thickens...

    So I decided to try a different approach to my problem and here's how it went. First I deleted the xml and itl files in iTunes directory and fired it up. Basically, I'm working w/ a blank slate. I then went to File -> Library -> Import Playlist and selected the amended xml file. After churning along a bit, it spat out an error: The file "library.xml" cannot be imported. An unknown error occurred (-50).

    So that's something I have to work off at least.
  3. thread starter macrumors newbie

    Nov 14, 2008
    Solved it

    Finally, fixed this - posted in case anybody runs across the same issue. The import process was obviously bugging out on the import of one file, so all I basically did was remove the offending entry from the xml file. Figuring out which file to remove though was the only mildly tricky part. Here's how I did it.

    Open your xml file and notice that the files are simply a bunch of 'key' tags followed by a 'dict' tag. The 'key' tag holds a number while the 'dict' tag encapsulates the actual metadata. The 'key' tag will be helpful for our purposes since as far as I can tell, it increments sequentially for each file. My 'key' tags started incrementing from 1316 - dunno why. Since I was only importing 6445 files before bugging out, I searched for the file corresponding to key 7761 (6445+1316).This got me real close to the bad file so from here it was only a matter of figuring out which file did not successfully import by comparing the xml file to iTunes. For me it was the file corresponding to key 7764. Anyway, I deleted the key and dict entry for key 7764, saved, reimported my library, and now all is fine.

    As an aside, after restoring my library, I then went to import the single problematic file manually w/o any problem so although the issue is fixed, it's cause is still a mystery.
  4. pvd
    macrumors newbie

    Mar 26, 2009
    Just had the same problem, this post was a godsend. Retained my dual music library folders. Thank you.
  5. SWD
    macrumors member

    May 3, 2011
    I had a different problem, but importing from the .xml file turned to be the solution. Then I came to this issue where I received this error message. I opened up the .xml file, followed your instructions for reading it and found the issue within the file. The file was missing in the library, but was reporting garbage text in the .xml file. I had access to export the library file again and it imported perfectly. Thanks for posting the solution.

Share This Page