How to transfer iTunes library between Mac and PC
You've put a lot of time into your iTunes library, creating just the right playlists, and rating every song you've got. Now you buy a new laptop and you've decided to make the switch - from Windows to Mac (or Mac to Windows). Sadly, transferring your iTunes library along with your playlists and ratings isn't just a matter of moving the music files. Sure, the song-specific metadata like artist and album will be copied over in the files, but the data you assigned, the playlists and ratings? Those live inside iTunes' internal database files which can't be simply transfered from PC to Mac.
Actually, the best way to transfer iTunes library is to use iTunes's built-in backup and restore. This copies the contents of your library to CD's or DVD's, and nowhere else. However, if you've got a 60 gigabyte library and you don't have time to stand around wasting burning dozens of discs, this way's for you. The method described here lets you copy the files directly from one computer to another and take your playlists and song ratings with you.
This guide would be a little complicated for new iPod user, if you want to transfer iTunes library easily, you can try this iPod Transfer for Mac (From Mac to PC) or this iPod Music Transfer (From PC to Mac), they can help you upload music to iPod and just two clicks to transfer them from iPod back to your new computer.
Step1. On the source machine. To ensure that both machines keep the same folder structure, on the source library, in iTunes' Preferences pane, the Advanced tab, make sure that "Keep iTunes folder organized" and "Copy files to iTunes Music folder when adding to library" are both checked.
Then, from the Advanced menu, choose "Consolidate Library." The consolidation process may take some time, depending on the speed of your machine and size of your library. When that process completes, you're ready to export your library data. From iTunes' File menu, choose "Export Library..." and save the Library.xml file somewhere on the destination machine.
Step2. On the destination machine. Now it's time to prepare the Mac, your destination machine. First, create a new iTunes library. (iTunes will do this automatically if it's the first time you're launching it; if you want to store your new library somewhere other than the default, hold down the Option key (Shift on Windows) when starting iTunes to create a new library.)
Just like on the source machine, make sure that "Keep iTunes folder organized" and "Copy files to iTunes Music folder when adding to library" are both checked inside iTunes' Preferences. Make a note of the folder where your new library's music files will live, and quit iTunes.
Now it's time to copy your music files from the source machine's music folder to the destination machine's music folder. You can do this over the network, or using an external drive. Just make sure the destination has all the same songs as the source.
Step3. Convert the Library.xml file from PC to Mac format. Now, the Library.xml file that you exported on the source contains all your music playlists and ratings, but it contains file paths specific to your PC. Macs and PC's deal with file paths differently; PC's use drive letters but Mac's do not. So in order to make it importable by your Mac, we have to find and replace the Windows paths throughout the file with Mac-friendly paths.
To do so, open the Library.xml file in a text editor. If you have a very large iTunes Library, like I do, this file could be several megabytes (18, in my case), so opening it might take more time than usual. If you can, use a machine with Lots of memory.
Now, you'll notice that the Library.xml file from a PC will contain, along with a lot of other plain text XML markup, references to music locations in this format: file://localhost/F:/path/to/iTunes/. Using a simple find and replace, change those notations to the destination path using Mac format, for example, file://localhost/path/to/iTunes/. Here's what my find and replace looked like, from the PC's F: drive location to my Mac's external drive named "Media":
Notice the Mac path does NOT include a drive letter, but the PC does. Replace the /path/to/iTunes/ with the folder's where your new library lives. Save the edited file. (Depending on the speed of your machine and size of the Library.xml file, this may take a few minutes.). Make sure you double-check that the source path was correctly replaced with the destination path; if this part isn't exactly right, you'll be screwed later on.
Step4. Import your Library. Now your new library is ready for all your hard-earned ratings and playlists. Launch iTunes on the destination machine. Even though you copied all the music to the right folder, iTunes doesn't see it. Yet.
From the File menu, choose "Import. . ." and select the Library.xml file you exported and edited from the source - then let 'er go. It will take some time, but iTunes will suck in all the playlists, and tracks with rating information into your new library.
When you're done, you'll notice that you have duplicates of standard-issue iTunes playlists, like the Top 25 Most Played, Music Videos, etc. You can delete those dupes. Also, that whole Determining Gapless playback process might take awhile in your new library, too.