727 Views 14 Replies Latest reply: Dec 5, 2005 4:01 PM by saltymcpepper
There is no feature to easily merge two iTunes Libraries together. You are on the right track with using the XML file. It is also good that the two Libraries do not have any 'overlap'.
There are two methods (in my mind) that may get you to the end-state you desire:
- Importing the 'Old' XML file and songs into iTunes directly
- Creating a 'temporary' iTunes Library using the 'Old' data, saving the important bits (Playlists and ratings), then importing that information back into the 'Current' Library
Let's attempt the former, before getting into the latter (if needed).
One caveat: Using the XML file to import information will definitely get your music files and Playlists into the Library, but I am not sure it will capture the ratings. While the ratings are a part of the XML file, earlier versions of iTunes did not completely read/import the entire XML file, and some music attributes were 'dropped'. This may be different now, with the later versions of iTunes. We'll see.
To correctly import the XML file, the songs need to be in the path designated within the XML file. Any songs not found (based on the XML paths) will not be imported.
You have two options: place the songs in the exact drive & path listed in the XML file; or mass convert the XML file song paths to where the songs are. You'll need to decide which is easier. If you have a text editor, mass replacing a specific character string is fairly easy.
Once the songs are in their expected spots, just open iTunes and 'File==>Import==>Browse to the XML file'. Your songs should be added to the iTunes Library.
Make sure that your settings are what you want. Do you want iTunes to organize the folders for you, and (more importantly), do you want iTunes to copy the 'old' files to the currently designated Library folder? If the files are currently in a structure you prefer, or the files are already copied into the iTunes folder structure, then you do not need to copy these files again. If the files are in a temporary location, then allow iTunes to copy them into its folder organization and then delete the temp files when you have verified the process completed as expected.
That is the high-level synopsis. Post back with any questions prior to starting.
Before you do anything, make a backup copy of the ‘iTunes Library.itl’ database file you now have. Store it somewhere safe. Also consider making a full backup of your music files (if you have not yet done so).
So the Playcounts did not re-import via the XML file? How about the Ratings? Did they come back in?
Seems as if iTunes will populate these attributes when writing the XML file for other programs to read, but will not (or cannot) read them when re-importing an XML file.
I guess that (reasonable) feature is still absent in the iTunes functionality. Wonder what else was present in the XML file, but did not get imported....
I figured that you would have the answer. Any reason why iTunes will populate the XML file with these attributes, but not read them back in? ...Other than just lack of programming attention?
Other than your 'SaveRatings' script (done in anticipation), is there any other way to restore these attributes from an XML file? Can your script extract the data fram an XML file?
Is there any way to recover from this if you did not make a backup of the ITL file and/or use the 'SaveRatings' script before the 'event'?
I figured that you would have the answer. Any reason
why iTunes will populate the XML file with
these attributes, but not read them back in?
...Other than just lack of programming attention?
I think this was done because the same code that writes the XML out for the library probably is used to write XML playlists out. And if you share your playlists with somebody else, you'd probably rather not have their ratings and such overwrite yours.
Other than your 'SaveRatings' script (done in
anticipation), is there any other way to restore
these attributes from an XML file?
Not to my knowledge.
Can your script extract the data fram an XML file?
Not at present, but it would probably not be difficult to modify or write a script to do just that. Not that I'm volunteering, mind you.
Is there any way to recover from this if you did not
make a backup of the ITL file and/or use the
'SaveRatings' script before the
No particularly easy way that I know of, no.
Thanks again, Otto.
Here's a hypothetical for you...
- Two separate Libraries on two Windows PCs
- No identical songs across the Libraries
- All the music files and the iTunes ITL database files available for each
- You want to merge the two while keeping the Ratings, Playcounts and such
- It's all legal across Libraries that you 'own'
As long as I could use your 'SaveRatings' script to save the music data of the Library 'to be merged', I could later add that data into the 'combined' Library, updating the music files I added. Correct?
In the case of the original poster, if he/she has the all music files and the ITL file, the 'Old' Library could be temporarily recreated on the current PC and the 'SaveRatings' script applied.
Restore the 'Current' Library, 'Add' the 'Old' music back in, 'Import' the XML file to recreate the Playlists, then apply the music attributes from the 'SaveRatings' script, previously run.
So...is this technically correct? Will it work (if done properly)? Seems to make sense to me.
As a secondary wrinkle....Any problems with having duplicate songs across the Libraries? Other than most likely updating the ‘Imported’ ratings & playcounts on to the ‘Current’ songs as well?
As long as I could use your 'SaveRatings' script to
save the music data of the Library 'to be merged', I
could later add that data into the 'combined'
Library, updating the music files I added. Correct?
Sure. The SaveRatings script is not picky about file location or anything other than the actual title/artist/album names. Makes it handy that way.
In the case of the original poster, if he/she has the
all music files and the ITL file, the 'Old' Library
could be temporarily recreated on the current PC and
the 'SaveRatings' script applied.
Ehhhh.. Slight problem there. When it's "saving" the information off, it will break if it tries to get the Last Played Time information for a track that does not have a proper file associated with it. This is an iTunes limitation that I never bothered to work around. In other words, if a track has an exclamation mark beside it, and you use the script, it'll likely error out. I could fix this, however, and simply not save the Last Played time info in that particular case.
As a secondary wrinkle....Any problems with having
duplicate songs across the Libraries? Other than
most likely updating the ‘Imported’ ratings &
playcounts on to the ‘Current’ songs as well?
It will work, but the script stops looking for a track when it finds the track it's looking for. Basically only one of these duplicate songs will get the rating and such applied to it.
It's not a particularly robust script, in other words. Given that I knocked it up in about an hour, I think it's held up quite well, but it does have its flaws.
AMD Athlon 64 X2 Dual Core 4200+ Windows XP Pro
"Ehhhh.. Slight problem there. When it's "saving" the information off, it will break if it tries to get the Last Played Time information for a track that does not have a proper file associated with it."
Yes. I remembered this from a previous answer you gave me a few weeks ago.
In my hypothetical situation, I would restore/recreate the complete Library: the ITL file and the underlying music files in their proper positions. There would not be any 'broken links'.
"Do you have a plan then?"
Always have a plan...will it work is another story.
See my post to Otto above for a theory: http://discussions.apple.com/message.jspa?messageID=1256201#1256201
You'll want to recreate you 'Older' Library on the current computer. That's not too hard if you can place the song files on the PC in the exact same location that they were in on the old PC.
Open the old XML file (use Word, a text editor, or similar) to view the data and determine what the complete path of the songs were. Post it back here.
Make a complete backup of your current Library (music files and database files) for safety. Note where they all are, just in case we need to move them temporarily. It may be best just to rename the current 'iTunes' folder to 'Current iTunes', then create another 'iTunes' folder for the old Library music and data files.
Copy the old Library music files into the location that iTunes expects. Copy the old ITL file into the 'iTunes' folder (where the current ITL file resides). Again, make sure you have a copy of the current ITL file safely tucked away for later.
Once everything is copied and in place, open iTunes. It should be a replica of the old version on the old PC. From there you can 'Export' all your playlists to XML files, and use Otto's 'SaveRatings' script to save your Ratings, Play Counts and Last Played attributes. See the link below to get it and how to use it.
Once all that housekeeping on the old Library is done, we need to restore the new Library:
- Close iTunes
- Move (drag) all the old Library music to another folder on the PC
- Move (or save) the old Library ITL file
- Place all the current Library music files back to where they were
- Do the same for the current Library ITL database file
- Open iTunes - You should see the current Library as before
- Edit=>Preferences: Set iTunes to copy music files to the folder and to keep iTunes organized (if this is what you want - most do)
- File=>Add Folder and browse to where the old music files are located
- Add them to the Library
- Finish running the 'SaveRatings' script to add the meta-data to your newly 'Added' music references
- 'Import' your saved Playlists to re-create them within the current Library
That should do it. This is obviously a high-level overview. Read it through several times and ask questions prior to implementing. If you have complete backups of the music and database files for both Libraries, then you can always recover from a misstep.
You can keep the Ratings, Play Count, Last Played attributes with Otto42’s SaveRatings tool:
See: http://discussions.apple.com/click.jspa?searchID=428299&messageID=1275577 for directions (also below):
“Download this: http://ottodestruct.com/itunes/SaveRatings.zip . It's a program, just run it like any other program. Run it on the machine where you're copying the info from BEFORE you move the files to the new machine. Click the "Save Ratings" button and it'll create a ratings.xml file. Now when you move the files, move the program and this file as well. Then after you make your new iTunes library, run it again and click the "Restore Ratings" button. Voila, all your information is back in the Library. Well, most of it anyway, it's not perfect. It'll tell you what songs it couldn't figure out though, and there's usually not very many.”