iTunes library, fixing a broken one or moving one 55

Posted by paul on July 20, 2008


I see some discussion about fixing busted iTunes libraries, either when moving one on the same computer or migrating to a new one. Here’s what I have found works for me. Bonus: no slow AppleScripts or payments (donations cheerfully accepted and squandered).

As an aside, if you are going to comment along the lines of “I just moved my music from one Mac to another and nothing broke so why is this so complicated?” please don’t bother. The title specifically mentions a BROKEN library, you dig? Or perhaps your library has outgrown the current location and you want to move it but retain access to it as your primary library and keep all your playlists and history. That’s what this post deals with, not replicating a working installation, but changing one to suit a new environment or fixing a botch attempt at it. Peace.
And for goodness’ sake, read all the comments: some good stuff down there.

First, what I have discovered about how iTunes manages music collections. There are two files it uses, one that is binary (ie, machine readable for faster performance on searching, sorting, add/edit/delete operations) and one that has the same information but in a human readable format (for a certain subset of humans who can read XML natively). The XML file is written from the binary file as a backup (check the dates to confirm).

Picture 16.jpg

iTunes will try to open the binary file when it starts up and if it’s not readable, it will re-create it from the XML file. That’s what we’re using to fix the damage or make any sweeping changes.

First, close iTunes. You’ll be working with files it uses/writes to and you’ll muck things up if you makes changes to files it has open and then your changes get clobbered, leaving the binary and the backup unusable. Don’t do that.

  1. find your Music folder/directory where these files live: you are looking for iTunes Library and iTunes Music Library.xml
    The XML file is a backup of the other file, which is the one iTunes uses:
    iTunes Library: data
    iTunes Music Library.xml: XML document text
    [NB for Windows users: you will be looking for iTunes Library.itl and iTunes Music Library.xml.]
  2. Move the iTunes Library file aside (rename it, put in your home directory, whatever). Create an empty file with the same name (or simply mangle a copy of it: seriously: this is where the backup copy comes in). If you are in the Terminal, you can just use touch(1), as in touch iTunes\ Library. You can also just open a file in whatever other editor you like and save it as iTunes Library.
  3. You’ll need to edit the XML file, in a text editor, not a word processor (not Word, as if I have to explain that). vi, emacs, pico, nano, TextWrangler, BBEdit, TextMate on the Mac side, NotePad/WordPad, et al on the Other Side. You are going to search and replace the current location with the new one. Every file/track/song has it’s own stanza in that file and within that, there is a Location key. You need to replace the old one — as an absolute path — with the new one.
    An example: <key>Location</key><string>file://localhost/private/Network/Servers/shuttle
    /usr/local/share/mt-daapd/media/Abbado_Berliner%20Philharmoniker/Mahler_%20Symphonie%20No.%205/01%20
    Trauermarsch.%20In%20Gemessenem%20Schritt.%20Streng.%20Wie%20Ein%20Kondukt.m4a</string>
    Picture 17.jpg
  4. A quick and dirty way to do it on the command line, ie, in the Terminal?perl -pi -e.backup s|oldpath|newpath|g iTunes Music Library.xml
    perl -pi.backup -e s|oldpath|newpath|g iTunes Music Library.xml

    This will create a backup file (cleverly called “iTunes Music Library.xml.backup”)

  5. Now, test it. iTunes needs to find that iTunes Music file and since it can’t read it (it’s empty or damaged), it will create one from the backup you just edited. Give that a minute or three to complete. See if your files are found and playable. This should also keep your playlists (which are just another XML stanza with the elements being track ID numbers).

This has worked for me more than once and if it’s reproducible, it should work for you. But note that I recommend a backup copy of the XML file. You can go back and re-do it from scratch if you get into trouble.

And I expect this is extensible in many interesting ways, like merging libraries from different users (something with diff and patch, perhaps?), switching from one repository to another (maybe a large home repository and a smaller traveling one). I’m not clever enough to figure those out, but if anyone else does, I’d love to hear about it.

[update] This looks interesting:

I had to do some more things with my iTunes library lately - like extracting all that ratings and exporting them into a new music player software I liked to test. I therefore wrote myself a little tool in C# that does the job of reading in the whole iTunes library and giving you programmatically access to that library. It only needs to have read access to the Mediathek.xml file iTunes stores in it’s music folder and you from there on can work your way through the bazillions of music tracks you may or may not have in your library. It even does the find-and-replace job a bit easier than the solution mentioned in the article above.

Trackbacks

Trackbacks are closed.

Comments

Leave a response

  1. Nixta Aug 06, 2008 18:14

    I’ve just been through this with iTunes 7.7.1 and whereas I was able to do the “iTunes Library” trick previously to migrate all my library from a PC to a Mac, this time it didn’t work. iTunes just created a new iTunes Library file with no songs in it!

    Instead I bit the bullet: I created an external drive named iTunesMaster and copied my library there. I created an Export XML file of my current library and modified the paths to reflect the iTunesMaster drive.

    I then created a new library on iTunesMaster/iTunes and imported the Export XML. It brought nearly everything over. I had to touch up my PodCasts and go through some Album Art, but that’s nothing too terrible.

    I now have my iTunesMaster drive on the LAN (attached to a Time Capsule, but it can be attached to the machine any which way you like, directly or via LAN as long as it appears as /Volumes/iTunesMaster). My wife’s machine or my machine can connect to it, and both stream to the same Airport Express depending on who gets up first and fires up iTunes.

    If performance is important, just unplug the drive from the Time Capsule and plug it directly into the Mac. It’s still called /Volumes/iTunesMaster! That also means, you guessed it, I can take it on holiday with me. In fact, if I’m travelling without my wife I can just take a copy off the external drive onto another (2 hours work while I’m doing other stuff). I just rename that second drive iTunesMaster and we have two copies of the library. They’re licensed by authorised computer after all, not authorised drive. If I were really into it, I could map a folder to /Volumes/iTunesMaster and not need to rename the drive, but this is plug-and-play.

    The only caveat. Don’t call the drive iTunesMaster if you need to use Windows machines as it’s not a valid FAT32 drive name!

    Why does it have to be so hard, Apple? Come on - make it iTunes core functionality to migrate libraries nicely!

    n

  2. josh Aug 06, 2008 19:31

    agreed, Apple should make a very easy way to transfer your library to a new comp. and build it right into iTunes, it is essential unless we all want to use the same computers for the rest of our lives!

  3. paul Aug 06, 2008 19:37

    I think Apple does make it easy to migrate (Migration Assistant, anyone?). It’s moving things around on the same ‘puter that can be perilous.

    As someone pointed out at TUAW, you can just use iTunes’ own “Consolidate Libraries’ feature but I suspect it’s not as fast as rsync. With a large library and a slow machine, it can take a long time since iTunes is hogging the UI while the job runs.

  4. Nixta Aug 06, 2008 21:30

    Consolidate Library is the poor man’s choice. That requires that you pander to their own naming scheme. I don’t think they make it easy to migrate at all. If you want to move from PC to Mac, the only sanctioned way is to burn your library to CDs and then reimport, consolidated or not, and actually even a Mac to Mac migrate has to stick to that now that I think about it (unless you’re something of a mini-amateur-hacker like we seem to be). How is that easy, sensible, or sane?

    I do like Apple. Don’t get me wrong, but I think that for someone who leads the way in online music distribution and listening, they make some seriously heinous mistakes. There’s no argument for them. Rule number 1: Make computer do the tedious crap. Rule number 2: See Rule number 1.

    That’s all that consumer computers should be doing. App developers should focus on tedious tasks and make computers do them. Instead we live in a world where computers do the stuff that wasn’t tedious before because it didn’t exist, and they do it badly. Back to basics, I think.

    Apple do better than most at Rule number 1. However, because of that people fail to notice where they do fail.

    If I can’t listen to some music and then queue up other songs to play after it, what’s the point in a personal portable music player, but does the iPod let you do that? No. I could do better with a record player on a trolley. Or two tape decks.

    Technology my ass.

  5. paul Aug 06, 2008 21:43

    I agree that Consolidate Library is less that excellent. In fact, I’m not sure it works 100% of the time. I have this throbbing sensation, like a remembered bruise, that it caused more problems than it solved.

    No, I like the quick and dirty end-around, until/unless they come up with a better way. Even the hints mentioned at TUAW about just resetting the library location in Preferences has left me high and dry.

    But what do you by this:

    If I can’t listen to some music and then queue up other songs to play after it, what’s the point in a personal portable music player, but does the iPod let you do that? No.

    I’m not understanding what’s missing. It sounds like On-The-Go playlists, but if you mean being able to cue up other tracks while listening to something and automatically going to the list you chose when that track ends, I don’t think that works, no. What I have done is simply start an On-The-Go playlist and while that first track is playing, fill in the rest of it.

  6. Richard Aug 07, 2008 01:17

    Your perl one-liner is slightly wrong. It should read:

    perl -pi.backup -e ’s|oldpath|newpath|g’ ‘iTunes Music Library.xml’
    [fixed. thx.]

  7. Ray Aug 07, 2008 02:45

    Much easier… All u do is move the library files out of ur iTunes folder, open iTunes, re-add all ur music (so it refinds all the songs locations and eliminates any wrong info, lost songs or dupes).
    Then select import from the file menu, and select ur moved Library.xml, and it imports ur Playlists.

    This rebuilds library file..

    Ray

  8. Nixta Aug 07, 2008 05:51

    Indeed, that’s what I meant. I find it huuuuugely frustrating. I’m listening to a song, it puts me in mind of a whole album I haven’t heard for ages. “Wow, that’s what I want to listen to once this is over, but I want to finish this song first coz I’m really enjoying it” says my brain. A computer should free me up to act on that thought there and then and then get on with things as before, rather than hold that thought and twiddle my thumbs as if I’m waiting for Windows to shut down, then when the song is over stop the player and start the album I was thinking of a few minutes before.

    Computer wait for me! Ug! Not me for computer!

    On-the-go on the old classic iPods was a little of the way there, *if* you were already in an on-the-go playlist and the song you were listening to was at the end of it.

  9. Jim Aug 07, 2008 06:59

    I’ve moved my iTunes library from one computer to another for years now simply by copying the entire Music/iTunes folder from one computer to the next. Everything has always copied over and worked fine. Playlists, ratings, etc…

  10. paul Aug 07, 2008 11:23

    I have a similar complaint. I would like to rate tracks I have listened to recently (ratings are one of the way I manage what gets on the iPod and what stays at home: I only have 10Gb of space on my olde skoole 3G), but you can’t do that without changing to that track. An embuggerance, but not the worst problem one could have.

    I think you could, in your case, simply add the album to the On The Go playlist and then start it once the track ends. Not effortless, but not too onerous, I think. Your call: my wish is impossible, as best I can tell, so lucky you ;-)

  11. Curtis Aug 09, 2008 20:24

    I’ve completely messed up my iTunes library, I’m thinking of possibly deleting(or really just hiding all my tracks from iTunes) then trying to import my entire library from my iPod (it has everything on it) How would I go about importing my music from my iPod, it’s only synced though none of the copy and paste of the iTunes Music Folder. Also I want the play counts and everything saved, which are all safely on my iPod, but no longer on my iTunes due to me trying to mess it up. Or if I plug my iPod in will it transfer over all the play counts from it?

  12. paul Aug 09, 2008 21:47

    You don’t say how you have messed up your library.

    First off, you don’t have to hide or move the tracks. It only knows about what’s in it’s lbrary database. Simply moving that aside will do the same thing.

    If you have synchronized this iPod before, it might work just fine. But not know what you think you have done makes it hard to be sure. Bear in mind, this is just a text file, replicated as a binary database.

    What might work: move aside the database files as listed above (after iTunes is closed). Copy all your music files back into iTunes, and it will recreate the library database as it may have existed. Then plug in the iPod and see if that works. If the music files on disk match the ones on the iPod, you’re done, as all your playcounts (for tracks that you had on the iPod) should update, as well as any playlists you had there.

  13. Sandra Aug 10, 2008 15:11

    My itunes library is empty and i can’t figure out how to put my songs back on it besides finding them on my computer and playing them in itunes. In that case after i put all of my songs back on there, when i plug my Ipod in it tells me that the ipod is synced to a different iTunes library. I want to find the original library which is somewhere in the lala land that is my computer. Can someone help me? if one of the above solutions could help me, will someone explain it so an idiot such as myself can understand it? Pretty Please.

  14. paul Aug 10, 2008 18:54

    Sandra: The message that your “ipod is synced to a different iTunes library” just means that iTunes and the iPod are confused and don’t think they have seen each other before.

    For nomenclature purposes, let’s call the two files that keep track of your music listening the Library. The music files themselves we will call music.

    I don’t know if you are running OS X or Windows. But whichever one, you should be able to find these files (iTunes Library and iTunes Music Library.xml). On the Mac you can use Spotlight or simply look in your Music folder and they should be in the iTunes directory. Make sure iTunes is shut down, then move them somewhere else. Then plug in the iPod and see what happens. If it complains, see what options it gives you. Don’t choose the “Erase and Sync to this library” option ;-)

    If you know where your music files are (probably in Music/iTunes/iTunes Music), here’s what you can try. Open iTunes and re-import those files: just drag them to the iTunes icon and let it do the rest.

    Then check to see if the stuff on the iPod is in iTunes. If it is, then “Erase and Sync” doesn’t cost you anything. Drop back by with more details.

  15. Patrick Aug 12, 2008 10:11

    Hey Gustave, what would you suggest if something happened to my library and now my itunes library has less file then what’s in my music folder… It seems to be an older version of my library as the new songs I added are not in the library anymore but the files are in the folder.

    Thanks

    Pat

  16. paul Aug 13, 2008 09:59

    Gustave isn’t in, but I’ll take a shot at this. What you could try, after you copy your Library files to a safe location, is simply re-importing your music tracks, then straining out the Duplicates. Depends on how many you have. You could also get lists of the files on disk and in the Library and compare them so you could just re-import the missing ones.

  17. Christopher Aug 19, 2008 17:59

    I transferred my library from my tower to my laptop earlier using the method above, and had a different number of songs listed in my Music library on the laptop compared to the original — but I figured out why after some checking. As it turned out, the difference was because of Digital Booklets (those PDFs Apple gives you with some purchased albums on iTunes). For whatever reason they don’t seem to be included in the XML file, so I had to add them in manually from the album folders back into iTunes. Once I did that, the totals matched.

  18. Mark Aug 20, 2008 16:55

    iTunes makes this so frustrating! I successfully migrated iTunes from a PC to Mac, but now that I want to migrate to a different disk on the same Mac it doesn’t work.

    I followed your instructions - the tracks are all there fine, but all my playlists have gone. On inspecting the XML file, iTunes has assigned new ID numbers to all the tracks…

  19. paul Aug 20, 2008 19:17

    On inspecting the XML file, iTunes has assigned new ID numbers to all the tracks…

    That’s . . . . odd. For that, I would, slow as it may be, do this within iTunes: choose the new iTunes library location in the prefs, and let iTunes do the heavy lifting. Changed ID numbers is outside the scope of anything I have seen.

    One thing I haven’t looked into is whether or not any of the opensource iTunes workalikes can help manage/massage these databases.

  20. Harold Aug 24, 2008 00:14

    this is bullshit. doesn’t work. caution is advised.

    [never let it be said I don't allow dissenting views. How does it go? better to remain silent and be thought a fool than to open your mouth and remove all doubt? --ed]

  21. andrew Aug 25, 2008 08:45

    Have tried 2 times to use backup discs to move my entire library from PC to MAC. Problematic both times. The first time I tried (50 cd’s worth of backup discs) the PC burned ‘em right, but the Mac would only read 70% of them. Out of my 10,000 song library, only 7,000 transferred over. Tried a second time, with less success. Tried an external hard drive from PC to MAC. No dice.

    Does this article posted by Paul on July 20th apply in the PC to MAC scenario? What worked for other folks (Mark on Aug 20th said he successfully xferred from PC to MAC) when transferring from PC to Mac?

    FRUSTRATED

  22. paul Aug 25, 2008 15:25

    Andrew @21: different scenario, outside the scope. But leave some information on how you burned the CDs (what program, burn rate, etc.) and perhaps we can help.

    OK, after some time to digest this (I was out of town for a couple of days), there may be easier ways to do this. Moving things around on CDs is slow and wasteful. Any way to network the two machines and share the disk from the Windows machine via samba? Or transfer them via [s]ftp, rsync? If you can do that, then the documented steps above will work, as you then just need to edit the plain text database backup and let iTunes create a new binary database.

  23. Mark Aug 31, 2008 15:04

    Hi - I figured out how to make it work. Previously I had my iTunes music folder moved to the new location before I updated the “iTunes Music Library.xml” file. I moved it back (from iTunes prefs) to the old location where all the music was, and then updated the xml file. Now not only did the music files import OK, but all my playlists were functional as before. The only thing changed is the import date in iTunes is now set to today for all my music, but as far as I can tell all other metadata was OK.

    Well, I thought that was clear, that iTunes had to be closed — ie no changes would be made to the file(s) — and the edits would reflect the reality after you moved your files. So : close iTunes, then make the changes to the music files’ locations and to the xml file where that is stored, then let iTunes catch up. If it’s not, I’ll see what I can do. — ed

    Also, in case it makes any difference for anyone else, this time round I deleted the non-xml library and replaced it with an empty file (using touch in terminal). Previously I had either manually corrupted the file or just deleted it.

    phew…

    Here’s hoping Apple will make this easier in the future!

    Andrew - I used essentially the same procedure for moving from PC to mac in the first place, though I can’t remember what the iTunes folder was set to when I did the import. It did work first time for me (unlike this time around moving the music on the same mac!).

  24. Steven Sep 02, 2008 17:39

    Thank you so much, you just made my life loads easier, i loaded the xml file in word, used find and replace to alter the location references and it repointed all of itunes to my external hard drive, your sir are a great man

  25. dag Sep 03, 2008 12:59

    hI,
    I upgrated my Mac OS x-tiger to Leopard (archive and install). Since then, When I try to open my i tunes, it pop’s up a message telling me: “Itunes library can’t be open, then it was made with an other version of itunes” or so… I still have all the files, I just can’t read open them.

    Any Idea?

  26. paul Sep 03, 2008 13:03

    I don’t have Leopard (at this point, I may as well for wait for Snow Leopard), but here are some suggestions:
    * backup the two files mentioned in the original post
    * damage the binary version or remove it and use touch(1) to create an empty one.
    * fire up iTunes and see what happens then.

  27. Mark Sep 04, 2008 01:08

    Hi Paul,

    Regarding your comment on my post, perhaps I wasn’t clear. I followed the instructions you posted (I think!) which are very clear. What you don’t mention is that the Prefs/Advanced/General/iTunes Music Folder Location setting is important.

    In my first attempt (where music transferred fine, but playlists didn’t) I had set that preference to the new folder before doing what you suggested (before I even thought about doing the move in fact - I wanted my podcast downloads in that folder). However, the move process you suggest only seems to work properly if that setting is set to the old location until after iTunes has imported the updated XML file.

    Maybe most people won’t have this setting different from their old iTunes folder in the first place, but on the basis of my experience it seems to make a difference, so might be worth checking for those who are having problems.

    [fair enough: I thought I had covered that. I’ll see about making sure it’s clear. Thanks for the feedback. Glad you got it sorted out. –ed

  28. Chris L Sep 04, 2008 23:08

    Brilliant… mostly. Allowed me to move my library between Macs without the use of migration assistant or consolidate library. Preserved playlists, play counts, ratings, last played date…

    Unfortunately, as previous posters have said, Date Added was reset on all songs, and PDF booklets were lost from the library.

    Had to search within the iTunes Music folder for all PDF files then manually drag them into iTunes and retag them… meh.

    Interestingly, the songs seemed to be added back in roughly the same order in which they had been added before… meaning my Recent X Added playlists were still mostly correct… odd!

    All in all, better than what I had before, which was a whole library of dead tracks. Thanks for the time saver!

  29. Jane Sep 09, 2008 23:21

    So I got a new Drobo and moved my library over stupidly and was too lazy to consolidate library..and that happened on the same day iTunes 8 came out. So this is with iTunes 8…

    I was about to leave a comment going “thank you” when I saw iTunes reloading from the XML file until I saw what happened… backstory: I saw a similar hint elsewhere, but they never mentioned creating a blank iTunes Library file, just updating the XML file, which was just a quick regex replace for me. iTunes wasn’t very happy with just the XML file and didn’t want to do anything with it. Had to create said file to get iTunes to reload from the XML file.

    However, for some reason, my XML file must have been out of sync with the rest of my library. I found out that loading from the XML file resulted in something like only 1/10th of my library being loaded, and it wasn’t like the most recently added files or the very first files, it was just a very random mix of my library.

    Anyway, I mean to say thanks for giving me the motivation to start over with my library without being pissed off, not so much the hint that didn’t work for me for some reason but isn’t your fault at all ;) I’m going from 240gb+ (almost no lossless at that, hah) to zero songs and slowly adding back only the ones I like.

  30. Maxy Sep 11, 2008 08:43

    Hi, I’ve got one question, does this one also work for Windows? If not, is there somewhere any explaination of how to do this with Windows. I know its a kind of stupid question, but anyway…

  31. paul Sep 11, 2008 11:20

    The only stupid questions are the ones we don’t ask. I *assume* it’s the same basic process (use Notepad or some other plain text editor, obviously).

    If anyone has done this in Windows, maybe they could add their 2¢?

  32. Mark Sep 13, 2008 07:13

    Great info here but alas I am still stuck on my own problem and am hoping for guidance from ya’ll.

    I am a Windows user and recently had to have my laptop reimaged. My iTunes files/library was stored on a external hard drive connected via USB2 cable (which worked quite well for me). After having my laptop reimaged, I downloaded iTunes 8 (I was previously using a version of iTunes 7). and, as I had done several times before, preceded to attempt to re-create my iTunes library for my new installation using these steps:

    1) Close iTunes.
    2) Copy “iTunes Music Library.xml” file to my desktop from my library location (external hard drive).
    3) Delete “iTunes Library.itl” file from my library location (external hard drive).
    4) Open iTunes.
    5) Click “File” and choose “Import”.
    6) Navigate to “iTunes Music Library.xml” i copied to my desktop.

    My current problem is that for step #5 above, in iTunes 8, there is no “Import” option in the “File” menu to choose from. Am I just missing something simple?

    Without doing steps 5 & 6, I obviously can’t see my playlists among other things.

    Help on this would be greatly appreciated.

  33. paul Sep 13, 2008 07:38

    Hmm, the File -> Import step is not something I use for this: as I noted above (and assuming this didn’t break in iTunes 8), simply create a blank iTunes Library file and let it build a new one from the edited XML file. The closest thing I can see is
    File ->Library ->Import Playlist but I suspect that isn’t for importing a complete library.

    Try it the way it’s laid out here and see how you get on.

  34. Mark Sep 13, 2008 10:16

    So after digging deeper here’s what I know to be true…

    – Under preferences my iTunes music folder is set to my library on my external hard drive.
    – I am almost certain that the xml… files located with my library on the external hard drive are not being used as I can rename/remove them and I can still see all my music (not including my playlists…) in the iTunes application.
    – If I use the “Reset” button to reset the iTunes music folder the default it is “C:\Documents and Settings\user\My Documents\My Music\iTunes\iTunes Music”.
    – If I look at that default location, there is another xml file there that I believe is being used. If I revert back to the default, I still see my music without my playlists.
    – When I look in the xml file in the default location (C:\Documents and Settings\user\My Documents\My Music\iTunes\iTunes Music\iTunes Music Library.xml) I see all of my music with the correct file location (my external hard drive) but none of my playlists are present.

    Here’s what I think I need to do to resolve…

    – Do the search and replace in my complete xml file to reflect the proper file location on my external hard drive.
    – Replace the xml file in C:\Documents and Settings\user\My Documents\My Music\iTunes\iTunes Music folder with my newly edited one.

    Here’s what I am confused about…

    – Why do all the >location< entries reference the C: drive (instead of D:, my external drive) for every entry in my “good” xml file located on my external hard drive?
    – I know I can do a search and replace to change the location prefixes to point to my external hard drive but I don’t understand why they are C:.
    – Was my previous iTunes install using an xml file on my C: drive that I wasn’t aware of? If so, how come the xml version (with C: file locations) resident with my library on my external drive up to date? From spot checks of this xml file, it looks like everything is up to date given recently added music and playlists are present.
    – Where should the location of my xml file be in my case as my music is on an external hard drive? In the default location (C:\…) or with my music on the external drive?
    – Why does iTunes use the xml file in the default location when I have set the “iTunes Music Folder” to point to my external hard drive.

    I realize that I probably haven’t fully understood how iTunes worked up to now. Despite this, I have somehow managed to configure it to work for me. :)

  35. Mark Sep 13, 2008 11:49

    After performing what I thought I should do to resolve worked. I can now see my playlists.

    I still wouldn’t mind input to my points of confusion above.

    Thanks Paul for your help to date. Much appreciated.

  36. paul Sep 13, 2008 12:37

    – Why do all the >location< entries reference the C: drive (instead of D:, my external drive) for every entry in my “good” xml file located on my external hard drive?

    That sounds wrong. If you close iTunes and move the directory or change it’s name, does iTunes still find everything upon relaunch?

    – I know I can do a search and replace to change the location prefixes to point to my external hard drive but I don’t understand why they are C:.

    Ah, re-reading your first Q, I see some confusion: the iTunes folder (where the database files live and generally in your home directory somewhere like ~/Music/iTunes) is different from the iTunes Music Folder which is where the audio files live.

    – Was my previous iTunes install using an xml file on my C: drive that I wasn’t aware of? If so, how come the xml version (with C: file locations) resident with my library on my external drive up to date? From spot checks of this xml file, it looks like everything is up to date given recently added music and playlists are present.

    See above.

    – Where should the location of my xml file be in my case as my music is on an external hard drive? In the default location (C:\…) or with my music on the external drive?

    It/they should be in your home directory (C:\…. or ~/Music/iTunes).

    – Why does iTunes use the xml file in the default location when I have set the “iTunes Music Folder” to point to my external hard drive.

    The Music Folder is not the database folder.

  37. Mark Sep 14, 2008 06:18

    Thanks for your help Paul. I think I’m getting a handle on all of this.

  38. David Milligan Oct 04, 2008 19:56

    “Only two industries refer to their customers as ‘users’”

    - Edward Tufte

  39. Teresa Oct 23, 2008 11:02

    Paul,
    Could you help me? I’m needing to re-create my itunes library in itunes 8-but the files where created in 7. I downloaded 8 before I created the library. Any suggestions? Teresa

  40. Judi Oct 26, 2008 09:28

    Okay, so I had to reformat my PC, I grabbed that xml file and saved that to a disc but I don’t save copies of my music to my computer, that is what the iPod is for, so none of the music was on my PC just my iPod.

    I don’t use iTunes to listen to music either, just to put music on the iPod then I delete the music off my PC and away I go.

    So, I grabbed the iTunes Library XML file, but I can’t get iTunes to accept it as my library, instead it just writes over it and blanks it out, I tried the file/import thing and it said it couldn’t because the songs weren’t there.

    I don’t want to attach my iPod and lose all my music either because I remember it wipes out the music on your iPod if it doesn’t match your library (which happened to me when I went from Germany to Canada with the iPod I lost about 10 gigs of music that I put on the iPod in Germany.)

    Any suggestions on how I just load my library without having the music already on the PC to match?

  41. paul Oct 26, 2008 10:53

    Okay, so I had to reformat my PC, I grabbed that xml file and saved that to a disc but I don’t save copies of my music to my computer, that is what the iPod is for, so none of the music was on my PC just my iPod.

    No, the iPod is for carrying around music, not for keeping the only copy you have of it.

    I don’t use iTunes to listen to music either, just to put music on the iPod then I delete the music off my PC and away I go.

    [sigh] That’s really not a good idea. You might have done better to just use the iPod in disk mode and manage your music manually. Or [shudder] buy some other player. iTunes is part of what makes the iPod better.

    So, I grabbed the iTunes Library XML file, but I can’t get iTunes to accept it as my library, instead it just writes over it and blanks it out, I tried the file/import thing and it said it couldn’t because the songs weren’t there.

    Well, first of all, it looks like you’re doing it wrong. First you need a deliberately broken iTunes Library file (see step 2 in my conveniently numbered steps above). The XML file can be used to rebuild the binary database. But I don’t think that will help you. If you rip songs to the PC, load them on the iPod then remove the files without removing them from iTunes, your library is, in a word, screwed.

    If you do get the library rebuilt, it will show a bunch of missing tracks. Because the tracks aren’t there. You deleted them. Seriously, what were you thinking? How expensive/valuable is disk space?

    I don’t want to attach my iPod and lose all my music either because I remember it wipes out the music on your iPod if it doesn’t match your library (which happened to me when I went from Germany to Canada with the iPod I lost about 10 gigs of music that I put on the iPod in Germany.)

    It sounds like you’re not using the iPod the way most of us do: iTunes is really part of, for lack of a better word, the ecosystem [yuck]. It keeps track of all the music you keep on the iPod, keeps it synchronized and updated, and most important, provides a copy of our music, your playlists, and listening history. And it only wipes out your iPod if you let it: it is possible to connect an iPod to a computer other than the one with the master library for charging purposes, let’s say.

    Any suggestions on how I just load my library without having the music already on the PC to match?

    That doesn’t make any sense: how can you have a copy of something and still have just one?

    Yes, there are ways to pull music off an iPod. I think the iPod is not the right solution for you. If you don’t want the computer/iPod integration — or actively work against it — you might want to consider some other player.

  42. Eliza Oct 29, 2008 17:01

    Sandra asked what was essentially my question back on August 10th, but they were only specific examples for OS X, and although I’ve located the ‘missing’ music, I can’t figure out how to get it back into itunes on Windows. Could someone help me out?

  43. paul Oct 30, 2008 11:50

    You want to share more details on what you have? Like the date and size of the files (the iTunes Library stuff mentioned above)? That’s the first step.

  44. allison Nov 02, 2008 16:47

    i just got an ipod .my husband thinks itunes will clog up my computer.if i ‘m just transfering my cd s will that harm my computer?there is war in the house…HELP!!

  45. paul Nov 02, 2008 18:13

    will that harm my computer?

    No. But keep in mind how much disk space you have and what you might be running at the same time.

  46. John Nov 04, 2008 22:13

    I get this dialog:

    The file “iTunes Library.itl” does not appear to be a valid iTunes library file. iTunes has created a new iTunes library and renamed this file to “iTunes Library (damaged)”.

    Launching iTunes then creates an empty library and overwrites my corrected XML file to match. So it’s supposed to be rebuilding at this point? From iTunes Library.xml or iTunes Library.itl.xml?

  47. paul Nov 04, 2008 23:19

    Did you back up the two files (iTunes Library.itl and iTunes Music Librar [I assume the same file name in Windows?])? See Step 2 . . .

    iTunes uses two files, one is binary (in Windows, the .itl file), the other more or less human-readable (the xml file). The xml file is a copy/backup of the other. If the xml file is overwritten, it’s game over unless you made a copy of both files.

  48. John Nov 05, 2008 13:41

    No worries, everything’s backed up. I can repeat this process as much as I like and it won’t make use of my corrected XML. It just gets blown away.

    You pointed out the “.itl” gives away that this file is from Windows. Maybe that’s my problem? I’m trying to correct the paths on my Mac, though Windows iTunes originally wrote the binary and XML library files.

  49. paul Nov 05, 2008 13:56

    Hmm, what happens if you take off the .itl extension? And I assume this is file has been damaged/truncated so iTunes sees it as needing repair?

  50. hagure Nov 11, 2008 19:26

    I’ve tried this method (and most of the others) a few times throughout the years and never had any luck. I always get the same empty library as John.

    Used iT 7,8 and Tiger (10.4.11) & Leopard (10.5.X). No .itl extension., used a touched replacement file, as well as empty txt file. The folder location is on an external, as is the library itself (I also tried it with the library residing in the ~/Music ƒ).

    Of note, my library is HUUUUUGE (around 200GB) so this might pose as a problem.

    In the end, I just gave up trying to fix my library and started a brand new one, transfering my playlists (around 200!) one by one. (I use a applescript from Doug’s to transfer my smart lists). I made a list for each of my ratings (including halfstars) and used these to re-rate my library.

    I “fixed” my broken library by creating a hard symbolic link (ln -s, aliases won’t work) to my new music folder, and placing it in the appropriate place (in my case, I had to create a folder hierarcy with the names and structure of my previous HD in the “/Volumes” folder. Hacky, but it works). Now when I open up my old library, most of the (!) are gone.

    I’ve also tried numerous programs (Syncopation, iTunes Ranger, SuperSync, etc.) to try to load the old and new libraries on different macs and use them to easily sync playlists and everything, but these programs were either too slow or unstable.

    I’ve gone through 3 main libraries over the years—not including my SoundJam days, from which there are still some great playlists yet to be transfered—so this manual process is quite time consuming. I’m about 80% done now, but fixing my playlists is an exercise in patience (iTunes won’t fix (!) songs in the playlists, so I have to manually search and add them). I try do a few every weekend.

    Thank GOD that metadata is written to the tracks. I use the “Grouping” & “Categories” fields for theme-based smart playlists, and if this resided in the .xml file, I’d cry. Good hint about the PDF files though, I’m sure I have a few lurking in there.

    So, while all my “date added” data is clobbered, everything else is intact, and at least I don’t run into random (!)s all the time.

    My lessons learned:

    *Keep iTunes music in one place (easier said than done with a laptop… when I’m not at home I just use Cog or streaming music)
    *Have an HD big enough for an ever expanding library (The reason why I made my first major library switch)
    *More ram helps a lot with big libraries (iTunes is based on a OS9 (Carbon) app coded in the 90’s…when 4GB was the size of your HD)
    *Symbolic links are great
    *Maybe its time to do some music spring cleaning (…nawww!)

  51. paul Nov 11, 2008 20:39

    Huh. Not sure what happened in your case though the reference to “a touched replacement file, as well as empty txt file” confuses me a bit.

    And yes, the Date Added stuff gets clobbered. I suppose a smarter person than me (read: anyone) could do some cleverness with the create date of the music file and use that as the Date Added value.

  52. hagure Nov 15, 2008 23:21

    As in I’ve tried touch itunes library and creating an empty text document with the same name.

  53. paul Nov 16, 2008 09:05

    Is case sensitivity an issue here?

  54. Jill Nov 18, 2008 12:47

    I accidentally deleted the ‘recently added’ and ‘recently played’ folders from my iTunes. These were “pre-set” folders by iTunes, so to speak, because I didn’t create the playlists. Is there any way I can get them back? I used the ‘recently added’ folder all the time and would really like to have it again.

    Thanks.

    Jill

  55. paul Nov 18, 2008 13:00

    That’s a Smart Playlist. You can just create new ones that meet your requirements.

Comments

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

Comments: