|<<>>|171 of 265 Show listMobile Mode

Synchronizing iTunes Libraries

Published by marco on

This is a synopsis of the instructions I found at New PC & moving itunes library, which didn’t strike me as concise or to-the-point enough for the less-savvy user.

Target Audience

This guide is for people who do not let iTunes organize their music for them.[1] It further assumes that you’ve already copied your music files (mp3, m4a, ogg, etc.) to the new computer. This guide will show you how to make iTunes on the new computer use the ratings, play count and other information from the old computer.

If you have the same folder for music files on both computers, you do not need this guide. This guide will work for transfers between Mac and Windows computers.


Quick Guide

  1. Copy the two iTunes Library files from the iTunes folder on the old computer to the one on the new machine.
  2. Using a text editor, open the XML file and search/replace the paths to the music files to point to the correct location on the new computer.
  3. Using a binary editor, open the ITL file, delete the entire contents and save it.
  4. Start iTunes, let it import the library from the XML file, then press “Yes” when it asks if it’s ok to ignore the “corrupted” library file.

Full Guide

Overview

iTunes stores your music library meta-data in two files, both of which are stored in your iTunes Music folder. This guides will refer to that folder as ~/Music; the real location is C:\Documents and Settings\<User name>\Music\iTunes on Windows and /Users/<User name>/Music/iTunes on Mac OS X. Inside this folder, you’ll see two (2) files and two (2) folders.

  • iTunes Library[2] is a binary file that contains all of your meta-data in a quick-loading database.
  • iTunes Music is a folder that contains all of your imported Music.
  • iTunes Music Library.xml is an XML file that replicates your meta-data in an easy-to-read text format.
  • Previous iTunes Libraries is a folder that contains backup files created during upgrades from other iTunes versions.

Copy the iTunes Library and iTunes Music Library.xml files to the ~/Music folder on the new machine.

Adjusting paths

The next step is to tell iTunes where the actual music files are located. You will have to adjust the library description for each of the song files.

Open iTunes Music Library.xml in a text editor[3]. Inside this file, there are several sections, but mainly two large one: one for tracks and one for playlists. Tracks have many, many fields, but the important one is highlighted below:

  <key>Tracks</key>
    <dict>
      <key>40</key>
        <dict>
          <key>Track ID</key><integer>40</integer>
          <key>Name</key><string>[Title]</string>
          <key>Artist</key><string>[Artist]</string>
          <key>Location</key><string>file://localhost/Users/Shared/Music/Funk/[Artist]%20-%20[Title].mp3</string>
        </dict>
        …

The line you will have to change is that for the Location key. In the example shown, the music library is found in /Users/Shared/Music. Replace this string with the location of the library on the new computer. Some tips:

  • Spaces are indicated with %20[4] instead of using a real space in the file name. If the location of the library has spaces, make sure to replace them.
  • Do not remove the file://localhost/ part at the front of the file name.
  • On Windows, the path should include the drive letter after the localhost portion. For example, if the music library is at D:\Shared\Music, the file location should start with file://localhost/D:\Shared\Music

You will not need to change anything for playlists.

Trick iTunes

If you start iTunes now, it will completely ignore the paths you put in, magically restoring the paths from the old computer and overwriting the file you painstakingly modified. Well done, iTunes. It’s actually loading the whole library from the other file, the iTunes Library. As long as iTunes can read from this file, it will not load from the XML file. If you remove the file entirely, iTunes will not load anything. Tricky, but not insurmountable.

  1. Open the iTunes Library in the same text editor as before. It is binary information and is supposed to look like that.
  2. Select all of the content and delete it.
  3. Save the file; it should be 0 bytes now.

Start iTunes

You’re done. Start iTunes and it will load the library from the XML file. Once it has imported this file (which can take some time with large libraries), it will ask you if it’s ok to ignore the corrupted iTunes Library. Click “Yes” and you’re done.


[1] On Windows, this file has an itl extension.
[2] That means that both the Keep iTunes Music folder organized and the Copy files to iTunes Music Library when adding to library are unchecked in the Advanced / General tab in the preferences.
[3] You will need an editor that can search/replace text in large(ish) files. On Windows, notepad should be able to open the file, but a more high-powered editor like jEdit is recommended. On the Macintosh, XML files open in the Property List Editor by default. You should use a text editor like TextWrangler instead.
[4] 20 is hexadecimal notation for 32 in decimal notation. The ASCII code for a space character is 32.