How to rebuild iTunes Library with altered file locations without losing playcounts|ratings etc My iTunes was set to make copies of all the music that it imported and keep it's own library within the iTunes folder. I wanted to delete my original files but deleted my iTunes copies instead. Now I have an exclamation mark beside all my music and since iTunes renames the files in it's own copy according to the ID3 tags, I can't simply replace my iTunes folder with my original files as the filenames and folders don't match. 

The brute force alternative is to manually point each missing file to the new file location but this does not seem like a very clever solution given I have over 5000 tracks. 

I don't want to reconstruct my library from scratch because I will lose precious listening and rating history from the past six years! Is there anyway I can fix this without losing my play counts and ratings?

I can a poor idea of rebuilding the file/folder structure on a new iTunes instance on another machine/account and copying the files back to the folder but this doesn't sound fool-proof. Any suggestions!
There are a few AppleScripts from Doug Adams that might help you:


Fix Broken Tracks will merge the data of "dead tracks" (iTunes tracks designated with "!") with the real track that you have re-added to your iTunes Library.
iTunes Track CPR will check your library for "dead tracks" and re-add them while keeping all the previous metadata intact. In order for this script to work, the files need to be moved back to the iTunes Music Folder. 
Music Folder Files Not Added displays files in iTunes Media folder which are not in the iTunes library.


It's important to read the manuals for these scripts before running them. Test a script only on a few tracks at first before running it on your entire library.