I have somehow screwed up my iTunes database such that iTunes/iTunes Music Library.xml contains network paths:


Most of the files are where they belong, in file://localhost/Users/Shared/..., but not all. Furthermore, all of the files are located on the local disk, e.g. /Volumes/media/Music/iTunes/iTunes Media/Music/Artis/Album/Track.mp3 has been copied into the local directory /Users/Shared/Music/iTunes/iTunes Media/Music/Artis/Album/Track.mp3.

I used File > Library > Organize Library..., and enabled the Consolidate files checkbox (along with Reorganize files in the folder "iTunes Media"), but this did not move all of the network-located files onto the local disk.

iTunes/iTunes Music Library.xml itself appears to be a write-only file, based off the contents of the binary file iTunes/iTunes Library.itl, so closing iTunes, editing iTunes/iTunes Music Library.xml to correct the paths, and restarting iTunes doesn't fix the issue.

Is there a way to update the iTunes database so that it uses local file paths instead of network paths for some of the files? (This impacts 9888 entries out of 11449 entries within iTunes.)

I have a similar/identical issue with iPhoto, in which some files are network located, and some aren't, and I don't know how to consolidate them to all be on the local machine...

  • I found the method below, which seems to nicely get around the 'ignore it or dupe all the darn data' issues with other methods I've seen. I haven't tested it myself but it looks sound. It also looks like it will preserve all other data, playlists etc, but let me know in comments if it loses anything & I'll add it to the answer, for further reference. Needless to say, backups are recommended. – Tetsujin Nov 22 '14 at 16:10

Reset the iTunes Library

Open the iTunes music folder in Finder ( it’s in your home folder / Music / iTunes) and drag iTunes Music Library.xml and iTunes Library.itl out on the desktop. This will reset iTunes next time you start it, but don’t start it yet. We’ll be working on the xml file, while the itl file is just there for backup.

Change the location of where iTunes keeps the music

In the iTunes preferences > Advanced, click on “change” next to the “iTunes music folder location”, and select your hard disk.

Look inside iTunes Library to see what the problem is

If your iTunes library is huge, it’s a good idea to use Terminal to look at the first few lines, which you can do easily with


(you can just type “head -n100 ” and drag the file onto Terminal to let OS X type out the name for you) The output will be something along the lines of

    <plist version="1.0">


Use sed to fix the path and create a new xml file



Here’s a breakdown of what the command does.

sed calls the sed command - it stands for Stream Editor

’s/…/…./’ sed will itself need instructions, which are strings hence the ’ (apostrophe). s/a/b/ means “if you find an a, substitue it with b”

file:\/\/localhost\/Users\/ME… this is the string we are looking for. Note that given that forward slashes are used by sed for s/…/…/, if you need them in the string you have to escape them with backward slashes

file:\/\/localhost\/Volumes\/HD1T\/ the string we are replacing with

< /Users/ME/Desktop/iTunes\ Music\ Library.xml The less than sign means “use this file as input” - in this case, the xml file I had dragged to the Desktop

> /Users/ME/Music/iTunes/iTunes\ Music\ Library.xml and this means “create this file as output”. We are asking sed to recreate the xml library file from the one on the desktop, but changing some bits around as it does so

Create a broken iTunes library


touch ~/Music/iTunes/iTunes\ Library.itl

which will create an empty file - broken enough for iTunes.

Restart iTunes

Now iTunes will finally pay attention to the xml file - it will show a dialog saying ‘Importing ‘iTunes Music Library.xml’…” This may take a while, even though it isn’t actually copying mp3 files around.

Source: http://gotofritz.net/blog/howto/fixing-itunes-cannot-find-music/

  • 1
    Brilliant! My google-fu never found that blog article :-(, and it never occurred to me to create an invalid .itl file... Meanwhile, while attempting to fix this I used iTunes Preferences to move the directory to another disk, then re-ran File > Library > Organize Library.... It's still ongoing, and requires lots of space; I'll report back if that works. I'll need to try the "invalid .itl file" trick with iPhoto. – jonp Nov 22 '14 at 17:07
  • 1
    Me neither - I shall be trying this method next time I update my windows iTunes, which shares the same library location as the Mac, but is never quite in sync, so periodically I have to go through all the grep/replace/import palaver. This looks a lot better option. In fact, no time like the present - will report back... – Tetsujin Nov 22 '14 at 17:09
  • Last time I tried this process, by find/replace the paths then manually importing to iTunes, it took about 8 hours. This method just took about 15 minutes for approx 6k tracks, including that it went back through 'gapless playback info' & 'audio volume' routines, though it did slow down a lot at about 5k tracks. It lost some artwork, too, but that was easily put right. Checked & unchecked survived, as did playlists, play count & star rating, but date added was all updated to today. Overall, not a bad effort. – Tetsujin Nov 22 '14 at 18:15

I haven't tried the much better sounding answer by @Tesujin. I'm certain his is much faster than what I did do.

This "solution" worked for me. It also consumes lots of disk space. However, as an added "benefit," it found several files which were overlooked...

  1. Click iTunes > Preferences...
  2. Click the Advanced tab.
  3. Change the iTunes Media Folder location, e.g. to another disk. Something with a path name that won't be too similar to the current path, to make grep(1) easier later.
  4. Click OK, and dismiss the Preferences window.
  5. Click File > Library > Organize Library..., enabled the Consolidate files checkbox, and click OK.

    This will result in copying over your library into the new location, "fixing up" the paths as it goes. This in turn means you need enough free disk space to store two complete copies of your music library.

  6. Quit iTunes.
  7. Verify the contents of iTunes/iTunes Music Library.xml, by grepping that it doesn't contain the previous path(s):

    $ grep Users/Shared 'iTunes Music Library.xml'
    $ grep Volumes/media 'iTunes Music Library.xml'

    What you want is no matches. What I actually got was several matches; the network mount was still being used for ~10 files, while the previous location had ~5 matches.

At this point, more investigation was warranted. As It Turns Out™, my network share had a case-sensitive filesystem, so the files which weren't copied were because of case changes, e.g. the song was actually in 'ArTist/Album/Song.mp3' while there was also an 'Artist/Album/Another Song.mp3' file; iTunes apparently doesn't like artists/albums which differ only in case, and there were ~10 of these.

Fixing these remaining issues was simple, if weird:

  1. Find the source file in Finder. (This may require copying the file via root shell on the NAS... ;-)
  2. Find the "bad" entry within iTunes.
  3. File > Get Info the entry.
  4. iTunes may complain that it can't find the file. Refer iTunes to the file in (1).
  5. Go to the File tab, and double-check the location entry. For example, the location was on my NAS.
  6. Click OK
  7. Drag the file in (1) onto iTunes. iTunes will now copy the file, thus removing the need for my NAS for this particular file.
  8. Verify that the location is fixed via (4) and (5).

What's funny is that if I skipped the initial steps (2)-(5), iTunes would copy the file but there would be two of the songs within iTunes, one on the NAS/wrong location, and one just added. I needed to Get Info the file first in order to "update" the file location.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .