I recently switched from Windows to the Mac at home, and was unable to find a comprehensive guide to migrating iTunes from Windows to the Mac. This post attempts to help fill that gap.
To follow this guide you should be comfortable using the Windows and Mac operating systems and a text editor. I recommend reading all the way through the instructions before beginning.
1. Run iTunes
First, run iTunes on the Mac. This should create a default iTunes folder structure in your home directory, at
~/Music/iTunes. When you first run iTunes it may ask if you want to scan your hard drive for music; do not allow iTunes to do this. It may also ask if you want iTunes to keep your music organized for you. Make sure you select the setting that matches your Windows iTunes configuration; you may need to edit the iTunes Advanced preferences to do so.
Now that you’ve gotten the initial iTunes configuration set up, quit iTunes before proceeding.
2. Copy Music Files
Next you need to copy your music files from Windows to the Mac. I recommend that you use an external hard drive to do this. Do not use a network connection to copy the files; as of this writing there is a bug in the Mac Samba implementation that causes some remote Windows directories to appear empty when they are not.
You may have configured your Windows installation of iTunes so that it didn’t organize your files for you. This is usually the case if you were using another system to organize your MP3 files prior to adopting iTunes. In that case, you may have an extra folder (for example,
D:\MP3) on your Windows machine that contains much of your music. You’ll want to copy that folder to your Mac home directory; I recommend
Whether or not you let iTunes organize your music on Windows, iTunes always organizes your purchased music for you. Therefore you will need to copy your Windows folder
My Documents\My Music\iTunes Music\ to your Mac as
3. Copy and edit iTunes Music Library.xml
Fortunately for us the Apple engineers used XML for the iTunes database. This means that the same file format works on both Windows and the Mac, and we can edit the file to tell iTunes about the new file locations.
Before you copy the file
iTunes Music Library.xml to your Mac, I recommend that you make a backup copy of that file in case you discover later that you didn’t mean to overwrite it.
Using your favorite Mac text editor (such as TextEdit, BBEdit, or Emacs), edit the file
iTunes Music Library.xml. Search and replace all of the file locations; for example, if your username on windows is Robert and your username on the Mac is Bob, you may need to change all occurrences of the string “file://C:/Documents%20and%20Settings/Robert/My%20Documents/My%20Music” to “file://localhost/Users/Bob/Music/”. If you didn’t let iTunes manage your files on Windows you will need to do another search and replace (for example, to change “D:\MP3″ to the corresponding new location you chose on the Mac).
Before proceeding to the next step, make a duplicate of your newly edited file. If you make a mistake in the next step iTunes will overwrite the file
iTunes Music Library.xml, so you’ll want to have a backup on hand in case that happens.
4. Create an empty iTunes Libary file
iTunes really uses the binary file
iTunes Library as the database file for your music. However, iTunes will fall back on the XML file when it discovers that the binary file is empty. Unfortunately it does not do this if the file
iTunes Library is missing or merely corrupt; in those cases it will delete your old XML file and create an entirely new and empty database. Therefore make sure you have a backup copy of your XML file from the previous step before proceeding.
Run the Mac Terminal app, and type the following command in the shell:
cat /dev/null > ~/Music/iTunes/iTunes\ Library
This will replace the file
~/Music/iTunes/iTunes Library with an empty file by that name.
5. Run iTunes
Finally, run iTunes. If everything has worked correctly, iTunes will rebuild its database from the XML file and you will be done. If some of your music is missing you probably made a mistake in step three and you’ll need to go back to that step and try again. If all of your music is missing, you probaby made a mistake in step four and you’ll need to restore the backup copy of your edited XML file and start with step four again.