Moving your iTunes media library without losing its metadata

iTunes about window

It’s always painfully annoying when your hard drive dies on you (especially if you haven’t made any backup). This just happened to poor me. :'( Fortunately enough, I have got into the habit of making weekly backups of everything I have. In other words, I didn’t lose any data at all. This should be a lesson to all of you who doesn’t back up your important files!

Anyway, I therefore needed to move my iTunes library to a new drive. It turned out that there is no easy way of doing so, especially if you haven’t selected the option in iTunes to “keep iTunes media folder organized”. I didn’t want to lose all the metadata (ratings, plays etc.), so I tried to find an alternative way. I eventually found a method after digging around in forums (pretty hard to find) which worked out alright in the end, involving modifying all the paths in the iTunes XML database file.

  1. First of all, just in case something goes wrong, backup your iTunes library data (make sure iTunes is closed before doing so). These files can be found in <user-folder>\My Music\iTunes+ for Windows, or in /Users/<username>/Music/iTunes for Mac.iTunes library files
  2. Move your media library to the new location if you haven’t already done so.
  3. Start iTunes and select “File -> Library -> Export Library” in order to export your library XML database file. Save it wherever you want, e.g. on your Desktop. Close iTunes when you’re done.Export your XML library
  4. Open Library.xml in a text editor in which you have a “find and replace” function. Notepad in Windows is not good enough for this purpose, I would instead recommend Notepad++. On Mac OS X, TextEdit would work fine for this purpose, but only if it is set to plain text mode (not RTF mode). The point is that you need a plain text editor.
  5. If the only thing that changed when you moved your files is the drive name (Mac) or the drive letter (Windows), then do a find and replace and change the old drive name to the new name. For example, “wdDrive” -> “LacieDrive”.
  6. This will take a few minutes depending on the size of your media library. Make sure to save when finished.
  7. Now, open up iTunes and delete all the files, which you moved to another location, from iTunes. You can do this by selecting them and then right-clicking on them and choosing delete. If prompted, make sure to select the option for keeping them.
  8. After deletion, import the previously modified Library.xml by selecting “File -> Library -> Import Playlist”. Depending on the size this can take a long time. In my case it took about 15 min.Import Library.xml back into iTunes
  9. Done. Check so that everything turned out fine by playing some of the songs.

It seems like Apple should provide an easier way to do such an essential task as updating your file paths after moving your media library. Hard drives die all the time, right!

  • Eric

    Unless I’m mistaken, you can move your entire library and simultaneously update the DB file by first changing the location of your media folder in iTunes>Preferences>Advanced, then using File>Library>Organize Library (it used to say “Consolidate Library”). iTunes should then copy the library to the new location, though it won’t delete it from the original one (not sure if that fact is contingent upon whether the new location is on a different drive), so once you’ve verified that the move worked, you can delete the old one manually.

    • admin

      Yes, that may work if you keep your media library located inside the iTunes directory. I’ve never set it up in that way. When I first set it up I thought in order for iTunes not to mess up my media library I should keep it at a separate location. Maybe it doesn’t actually do anything bad, but I just never tried it out. So, what you are suggesting would not work for me since I’m keeping it at another location separate from the iTunes directory. Anyway, thanks for your input!

  • Paul

    Thanks for this!
    I had been trying to find information on modifying the xml!

  • anon

    thanks

  • Didge777

    WOW! how laborious when .wav .m4a .mp3 etc supports metadata when files are transfered but apple stiil hate conforming to make it easy for average Jo Public.

  • Ni5hant

    gr8 technique…
    really helpful…!!