Moving and Organizing iTunes Music Files
I’ve been looking for this solution for awhile but only just stumbled across it. Over the years I’ve built up a sizeable collection of music from CDs, family members, friends, free downloads, iTunes purchases, Amazon purchases, etc. Unfortunately, I never restricted myself to a consistent convention for storing and keeping track of these different files.
What I need is a way to pull all of the physical files into one place from which I can organize and run backups on those files. Accompanying those files, however, is a wealth of meta-information in the form of ratings, playlists, play counts and album information that I don’t want to lose.
Solution: iTunes now includes a “Consolidate Music” option under the “Advanced” tab. Running this process will copy every file listed in your Music library to the home location (this setting: Edit -> Preferences -> Advanced tab). In my case, I ran this process once, moving everything to an external hard drive, deleted the original copies of the music, and then running it a second time to copy everything back to a single folder on the local drive.
Update: “Copying music failed. The file name was invalid or too long.”
- This is a result of filenames being too long, generally a result of artist and album information included directly within the file name.
- To get around this problem, open up the file My Documents/My Music/iTunes/Itunes Music Library.xml and search for the location of the directory you’re moving things from. The first instance of this directory will be that associated with the file iTunes had trouble with. Navigate to this file and shorten its name to something more appropriate. Next, find the song in iTunes, double-click on it, choose “yes” and find the newly renamed file. You can now resume the consolidation process, repeating these steps whenever iTunes has problems.
- The process may sound daunting but my collection includes ~6000 songs and encountered only 6 such errors.

August 13th, 2008 at 3:05 am
Thank GOD someone out there had an answer for me. I’ve been trying to figure out the consolidation problem for hours, and this has finally fixed it. Thanks!
October 3rd, 2008 at 11:09 am
This worked! Awesome stuff. DAMN YOU PANIC AT THE DISCO WITH YOUR RIDICULOUSLY LONG TRACK TITLES!
December 24th, 2008 at 9:48 am
hi, i don’t completely understand what to do here. Can someone please kindly explain it to me or give me a simpler solution please? I’m begging. Thank you
February 9th, 2009 at 10:50 pm
Thanks for this tip. Since my music files were being consolidated from multiple different locations, I browsed through My Documents/My Music/iTunes/Itunes Music Library.xml until I saw a location that wasn’t the new location of my iTunes folder. The first file had a long title. As you suggested, I renamed the file on the old location. Then tried to play it in iTunes. It then asked if wanted to locate the file. I chose the shortened name and then went on to consolidate the library. This time it completed successfully.
June 6th, 2009 at 4:41 pm
Awesome. This worked! I tried another script thats been floating around out there with no luck. This took a while, but it got the job done!
June 30th, 2009 at 1:37 am
Excellent tip. This and a little perl coding made my life much simpler.
January 8th, 2010 at 11:38 am
Thank you very much. I was afraid that there was no solution, but yours worked perfectly. And for the record out of 3000 songs I only had to change 2. It was quite simple to find the filenames in the XML file; I used text editor to do a search for ‘Locationfile://localhost/X’ where X was the remote disk.
January 13th, 2010 at 7:55 am
Hi. thanks for your clarification on this issue.
I need a little help however.
I don’t understand the most crucial part.
With wich program do I open the xml file and how do I find the first instance.
quote:”open up the file My Documents/My Music/iTunes/Itunes Music Library.xml and search for the location of the directory you’re moving things from. The first instance of this directory will be that associated with the file iTunes had trouble with”
I would be glad if someone could point that out to me.
Thanks a lot.
Marc