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).

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.
- 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[NB for Windows users: you will be looking for iTunes Library.itl and iTunes Music Library.xml.]
iTunes Music Library.xml: XML document text - 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 intouch iTunes\ Library. You can also just open a file in whatever other editor you like and save it as iTunes Library. - 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>
- 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.xmlThis will create a backup file (cleverly called “iTunes Music Library.xml.backup”)
- 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.

79 Comments
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
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!
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.
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.
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:
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.
Your perl one-liner is slightly wrong. It should read:
perl -pi.backup -e ’s|oldpath|newpath|g’ ‘iTunes Music Library.xml’
[fixed. thx.]
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
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.
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…
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 ;-)
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?
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.
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.
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.
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
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.
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.
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…
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.
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]
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
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.
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.
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!).
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
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?
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.
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
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!
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.
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…
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¢?
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.
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.
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. :)
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.
That sounds wrong. If you close iTunes and move the directory or change it’s name, does iTunes still find everything upon relaunch?
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.
See above.
It/they should be in your home directory (C:\…. or ~/Music/iTunes).
The Music Folder is not the database folder.
Thanks for your help Paul. I think I’m getting a handle on all of this.
“Only two industries refer to their customers as ‘users’”
- Edward Tufte
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
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?
No, the iPod is for carrying around music, not for keeping the only copy you have of it.
[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.
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?
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.
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.
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?
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.
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!!
No. But keep in mind how much disk space you have and what you might be running at the same time.
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?
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.
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.
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?
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!)
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.
As in I’ve tried
touch itunes libraryand creating an empty text document with the same name.Is case sensitivity an issue here?
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
That’s a Smart Playlist. You can just create new ones that meet your requirements.
My hd was very full. I added a new hd to my computer (mac) and moved my itunes folder to the new hd. I redirected my itunes to see the songs in the new hd. My problem is all of my playlist songs do not see the new location. I have to go into the itunes folder in order for itunes to recognize each song. I have over 5000 songs. This is very tedious. There has to be an easier way for the songs in my playlist to recognize the new location of my songs other than finding each one. Please help.
Did you read the instructions or the comments? Can’t make it any easier w/o doing it for you.
Paul–I’m using iTunes with Windows XP, no iPhone.
Suddenly, out of the blue, an empty opening screen. No files in the library.
Can I solve this problem by simply downloading the latest version of iTunes?
I sure hope the answer is yes. David in Bangkok
Probably easily fixed but not that easily ;-)
Worst case, you have to re-import everything again and lose play counts, playlists, history, etc. The first step is to find the data files mentioned in the original post and see what state they are in.
Paul–The files seem to be all okay. I have no problem with re-creating my eight or ten podcast subscriptions.
The sort of under-the-hood tinkering that you talk about at the top of this thread is way, way, way beyond me.
Should I first remove the existing program and then download iTunes8 (or whatever it is)?
Thanks a million for your help. David
I am a real novice when it comes to using terminal and have never tried to edit an xml file before and am confused about step 3. Right now the xml file is searching on my computer’s hard drive but I need to point it to my external.
ex: Locationfile://localhost/Users/bashomosko/Music/iTunes/iTunes%20Music/01-method_man_and_redman-how_h/Unknown%20Album/01-method_man_and_redman-how_high_part_2_(dirty)-ego.mp3
but I’m not sure how to write the replacement to my external hd where my music sits. Also, If I fix the text of the first song in the xml file, save it, and open itunes, will it find the rest of my files automatically? I’m just a bit confused as to whether I have to edit every strand in the xml file to redirect it. Again, pardon my naivete as I am a novice but anxious to get this sorted out.
Thanks!
Basho, you will need to search and replace all instances of that path in the whole file. It won’t find the other files if you only tell it where one is ;-)
Make sure you back up the old files (as noted in the instructions), grab a copy of TextWrangler if you don’t have a good text editor, and see the examples. Come back if you’re still stumped. No need to use the terminal if you don’t want to.
I hooked up an ext HD to my overflowing PC in October. I backed up the 20+G iTunes Library to DVD–9 discs’ worth. (I understand a disc backup contains all metadata?) Then I moved the iTunes Music folder-properly-to the external HD. All was perfect in my iPod world. Then my teenaged son blew up the computer, and a techie friend just reformatted it–didn’t ask first, no attempt at data recovery-like the library database files…soooo I had to download iTunes 8 on this clean old PC, but I’ve done nothing with the new iTunes install yet out of fear. The intact library (pre-vers. 8) sits on the external, but I have no matching .itl/.xml files. Then dear husband buys himself a new Nano, and starts importing CDs–so he’s begun a new library! So…do I delete *everything*, re-install iTunes 8, restore the library backup from the DVDs? I saw your instructions for rebuilding the database files, but I’m…not really understanding the binary thing and the replacing the path, etc. I’ve read everything thus far, but it’s late and I’m cowardly, maybe in the a.m. I’ll reread, and you’ll give me a shove, and…thanks for tolerating this advanced beginner PC user. p.s. if I can salvage the library without too much pain, sans the playlists, I guess I’ll manage but I’m a fitness instructor and there are lots of imported exercise CDs that I had to manually pull into playlists because they all were called “track 01″, etc. TMI, sorry.
thanks, works like a charm! moved a library with playlists and all counts etc from itunes 7.x to 8.1, on xp to vista.
edited the xml file and created a damaged itl file as suggested and poof, magic :)))
Hi all. I’ll cut to the crux of my problem.
I’ve followed the advice above and changed all of the locations of my files. When I do the “find and replace” in iTunes it finds 49k occurrences, which seems about right because I have 45,670 songs in my library. But when I open iTunes and it rebuilds from the .xml file, my library suddenly only has 2,420 songs. The songs that show up aren’t random–they were all added to my library on the same day. (Not the most recent batch of songs I added either.) Also, iTunes has added a smart playlist called “music” that shows all of the 2,420 songs added. I’ve double-checked to make sure all of the music is in the proper folder where I’ve told iTunes to look, and it is. Any ideas why it’s not finding everything?
In the above message, I meant to say that TextWrangler finds 49k changes in the xml file. Sorry.
This also may be of note:
When I open the fixed .xml file in TextWrangler, it shows all 49k of the songs, but once iTunes has opened and automatically re-saved the .xml file, that new file shows only 2420 songs. So something is happening when iTunes creates a library from my .xml library and the app isn’t reading the whole thing.
I’m confused, please can someone dumb this down for me.
Old computer is a Dell PC running on XP. iTunes library I *think* is stored in 2 places… (long story, my iTunes got wiped and I’m not 100% sure where all my files are).
New computer is an iMac (not sure on OS? MEMORY 065-7993 4GB 1066MHZ DDR3 SDRAM – 2X2GB, HARD DRIVE 065-8000 1TB SERIAL ATA DRIVE).
Anyway… I was following the recommendation to consolidate my library in one location. I did NOT have enough room on my Dell to consolidate. I have an external drive and I consolidated everything to THAT drive. I then copied that file that was consolidated onto my new computer (the iMac). I think all the songs moved, but I was under the impression that playlists and play counts could also migrate?
Ouch. This may not have worked as you expected. Copying outside of iTunes, as in just dragging files/folders around, can mess things up. Fortunately, it’s easily remedied with varying degrees of thoroughness: the more times you do things like this, the greater the risk of losing history, play counts, and other metadata. I would back up a step. Take the drive with the consolidated files and add it to the iMac. Now proceed as you have here:
I got stumped at this set of instructions:
PC-Mac – Copy across your library file – Now find the ‘iTunes Library.itl’ file on your Windows PC (it should be in the ‘My Documents – My Music – iTunes’ folder). Copy this across to your Mac’s ‘iTunes’ folder (note: this is not the ‘iTunes Music’ folder but is usually one folder back from that – you have the correct folder if it has the ‘iTunes Library’ and ‘iTunes Music Library.xml’ files in it). Now, delete the ‘iTunes Library’ file on your Mac, and then rename your newly copied across ‘iTunes Library.itl’ file to ‘iTunes Library’ (i.e. remove the .itl from the end). This has given your Mac’s iTunes a new library file pre-populated with all the extras you wanted to keep from your old library.
If I consolidated to an external drive – where do I find this ONE file??
This should be in your home directory. Open the Finder and in the lefthand tab, you should see a Music folder. Open that and open the iTunes folder in there. Your files should be there. Remember the iTunes directory is not necessarily where your music files are and the iTunes database files (confusingly named iTunes Library and iTunes Music Library.xml) are not your music files. But they are the files iTunes needs to have to work.
also, a lot of my artwork seems to be missing.
That should be on the PC: look for a directory called “Album Artwork.” Probably in “My Documents – My Music – iTunes.” Failing that, you can just tell iTunes to re-fetch it all.
Can anyone help? Or refer me to a site that may walk me through this a bit?
Thank you!!
Thanks for the fast response! I did copy the consolidated library folder and simply dragged it onto the iMac.
So… when you say the .xml filed should be in my home directory… am I checking on my external drive or am I “chancing” it and looking for it on my Dell?
Thanks again!
The iMac file will be .xml and the Windows version (on the Dell) would be .itl (for iTunes Library, I assume). And it won’t be on the external drive. That’s where the music files are and the music files are not the library/database files.
So you could shut down iTunes, move the two files on the iMac somewhere (a folder called “old” is fine), move the files from the Dell into place, make sure the names are right, and open iTunes again. Alternately, you could simply move the .itl file and change the .itl to .xml and it may just magically build a new library database.
Hi,
I came across this article from TUAW after some frantic google searching.
Using OS X leopard using iTunes 8.x
iTunes 8 seems to do things a little differently but I’m not sure what, so your mileage will certainly vary.
Plugged in my new external HDD.
Copied the entire /users/Music/iTunes folder to external-drive/media/iTunes
Option clicked on the iTunes icon in the dock and selected the library within the external-drive/media/iTunes folder
iTunes loaded up looking all well and good with all songs and playlists in tact. anytime i actually try and play a song i get “cannot locate file..” message. bummer.
have tried your technique just now of screwing with the “iTunes Library” file and changing all the filepaths within the .xml file.
Are you sure the paths you changed are correct? Double-check that just in case.
upon opening iTunes after the changes, it does indeed say the library is corrupt and uses the .xml file to build the database… so finger crossed..
but when it finishes building the database, all the playlists are there but the music library is only a fraction of the size… only 159mb instead of 70gb!!
clicking on playlists shows no songs as they are not present for some reason in the music library.
when i put the original “iTunes Library” file back in place (after quitting itunes of course), and then re-open iTunes, all songs are present and iTunes reports that I have 70gb music blah blah… although it cannot find any of them.. lol
If you “Get Info” on the missing file, it should give you an option to go find it: might be worth doing that and then comparing a fixed file with one that’s broken to see what difference there may be.
very confused now… please are you able to assist by email please?
many thanks paul
just to update on my situation..
i have managed to copy all external-hd/media/iTunes back to the original location it was on the /users/music/iTunes and also restore the itunes Library & iTunes Library.xml back from time machine… so iTunes is now working again to the same position i was at about 4 hours ago before i started the new external hdd stuff!
so now i want to try the whole thing again, but make it work – but will wait for you advice this time rather than just plough in!! lol
hurry hurry :)
Over the last day or so, I have learnt more about the innards of iTunes than I ever wished to know. I wish I had stumbled upon this ages ago. Completely fixes “the original file could not be found” problem that many people seem to have encountered, and now that I’ve inserted this as a comment will hopefully find this solution.
Thank you very much Paul.
PC. Problem is ugly. was in process of opening iTunes to add downloaded song. Pop up box msg states cannot load iTunes library. I quit. Now says library is damaged. Gives me a new one with what looks like most but not all songs. NO PLAYLISTS! Yes, I cried. Cannot restore to earlier date. Not all on iPod, it’s only 8G….gift giver thought that was enough. (Butthead. Help?
You may want to avail yourself of the instructions. You might be OK if you can make a copy of the backup file before iTunes clobbers it. Quick summary: there are two files, a binary (machine-readable) database file and a text file backup. If the text file backup is OK, iTunes can rebuild the binary file (the one it uses) from that. So check your dates and file sizes in the iTunes directory and cross your fingers that the text file is older than the binary (the filenames escape me at the moment but I think it’s .XML for the file and .itl for the database.
This post got my hopes up! Alas, this doesn’t appear to work in iTunes 9.
I edit my XML file, save it.
I then create a blank .itl file.
When I re-launch iTunes, it just names my itl file as damaged and then opens with a blank library. It doesn’t seem to make an effort to rebuild the library based on the XML file.
Sorry about that. I think Apple has “improved” iTunes in some unhelpful ways since 7.x. –ed
Might as well ask this here. I’ve been whoring this question out all over the web, and no-one, not even Apple Support has been able to help. Here goes:
I keep getting the “damaged library” message when I open iTunes. This began happening shortly after I upgraded to iTunes9 (which I don’t think is the problem, will explain later). After iTunes “reconstructs” my library file and renames my previous one “damaged,” I’m able to use iTunes for that particular session. God forbid I shut down iTunes, though. Every time I re-open iTunes, I get the damaged library error message.
Here is what I’ve done so far:
1. Called Apple “expert” support. They recommended uninstalling iTunes, quicktime, bonjour, etc and reinstalling. Not helpful.
2. Pulled out my library.itl and my library.xml files, open iTunes, and tried to reimport from these files. Worked fine… until you try to restart the computer, or open/close itunes.
3. Followed the knowledgebase articles on Apple for “recreating your library.” Again, works fine, so long as you never shut down itunes or your computer.
4. Uninstalled iTunes 9 and downgraded to iTunes 8. Same problem. (this is why I don’t think it’s an iTunes 9 problem)
5. Copied my entire library over to a 1TB external drive (thinking my HD might be nearly caput), reimported the songs… same problem.
6. Said many curse words, kicked the dog. Same problem except now my wife wants me to start going to church and the dog just growls at me.
What I’ve think might be going on: Something funky is going on when the computer or itunes is shut down. That funky something, whatever it is, is corrupting my library file.
Any ideas on how to pinpoint the problem?
I’m at my wits’ end. The next step is alcoholism!
I anxiously await some words of wisdom.
These instructions are not 100% guaranteed to work as they did in iTunes 7. Not sure what changed but people using iTunes 8 reported it wasn’t working as well. iTunes 9 is unknown at this point.
OK, here’s something you can try. In File -> Library, see what happens if you export, then shutdown cleanly. You could compare the file it creates with the one that iTunes writes on exit and experiment with swapping it into place.
Also, try moving the library w/in iTunes by changing the Media Folder location (in Preferences -> Advanced). Again, let it work, then quit iTunes and see if the file(s) look sane, as far as sizes and modification times.
Well, for the record this worked for me today (mostly) on iTunes 9 on windows – iTunes rebuilt from the XML file but then had to recheck all the audio volumes etc. as if they were new tracks – it also lost a good portion of the artwork which I had laboriously added (even for music that I had not moved) – so if this is important to you, beware. Thanks for this tip though, saved me hours!
Post a Comment