iTunes: Move files off a network drive I have somehow screwed up my iTunes database such that iTunes/iTunes Music Library.xml contains network paths:

&lt;key&gt;Location&lt;/key&gt;&lt;string&gt;file://localhost/Volumes/media/Music/iTunes/iTunes%20Media/Music/Unknown%20Artist/Unknown%20Album...&lt;/string&gt;


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...
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


  head -n100 /Users/ME/Desktop/iTunes\ Music\ Library.xml


(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


  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
    &lt;plist version="1.0"&gt;
    &lt;dict&gt;
      &lt;key&gt;Major Version&lt;/key&gt;&lt;integer&gt;1&lt;/integer&gt;
      &lt;key&gt;Minor Version&lt;/key&gt;&lt;integer&gt;1&lt;/integer&gt;
      &lt;key&gt;Date&lt;/key&gt;&lt;date&gt;2012-08-13T21:09:21Z&lt;/date&gt;
      &lt;key&gt;Application Version&lt;/key&gt;&lt;string&gt;10.6.3&lt;/string&gt;
      &lt;key&gt;Features&lt;/key&gt;&lt;integer&gt;5&lt;/integer&gt;
      &lt;key&gt;Music Folder&lt;/key&gt;&lt;string&gt;file://localhost/Volumes/HD1T/Music/&lt;/string&gt;
      &lt;key&gt;Library Persistent ID&lt;/key&gt;&lt;string&gt;C326B89DCF4457DF&lt;/string&gt;
      &lt;key&gt;Tracks&lt;/key&gt;
      &lt;dict&gt;
          &lt;key&gt;41557&lt;/key&gt;
          &lt;dict&gt;
              &lt;key&gt;Track ID&lt;/key&gt;&lt;integer&gt;41557&lt;/integer&gt;
              &lt;key&gt;Name&lt;/key&gt;&lt;string&gt;Fifths (Jazzanova 6 Sickth Mix)&lt;/string&gt;
              &lt;key&gt;Artist&lt;/key&gt;&lt;string&gt;Ski&lt;/string&gt;
              &lt;key&gt;Album&lt;/key&gt;&lt;string&gt;Jazzanova: The Remixes, 1997-2000&lt;/string&gt;
              &lt;key&gt;Grouping&lt;/key&gt;&lt;string&gt;where:de&lt;/string&gt;
              &lt;key&gt;Genre&lt;/key&gt;&lt;string&gt;ambient-synth-90s&lt;/string&gt;
              &lt;key&gt;Kind&lt;/key&gt;&lt;string&gt;MPEG audio file&lt;/string&gt;
              &lt;key&gt;Size&lt;/key&gt;&lt;integer&gt;19718194&lt;/integer&gt;
              &lt;key&gt;Total Time&lt;/key&gt;&lt;integer&gt;482925&lt;/integer&gt;
              &lt;key&gt;Disc Number&lt;/key&gt;&lt;integer&gt;2&lt;/integer&gt;
              &lt;key&gt;Disc Count&lt;/key&gt;&lt;integer&gt;2&lt;/integer&gt;
              &lt;key&gt;Track Number&lt;/key&gt;&lt;integer&gt;1&lt;/integer&gt;
              &lt;key&gt;Track Count&lt;/key&gt;&lt;integer&gt;10&lt;/integer&gt;
              &lt;key&gt;Year&lt;/key&gt;&lt;integer&gt;2000&lt;/integer&gt;
              &lt;key&gt;Date Modified&lt;/key&gt;&lt;date&gt;2008-12-05T14:26:06Z&lt;/date&gt;
              &lt;key&gt;Date Added&lt;/key&gt;&lt;date&gt;2012-07-14T07:42:37Z&lt;/date&gt;
              &lt;key&gt;Bit Rate&lt;/key&gt;&lt;integer&gt;320&lt;/integer&gt;
              &lt;key&gt;Sample Rate&lt;/key&gt;&lt;integer&gt;44100&lt;/integer&gt;
              &lt;key&gt;Play Count&lt;/key&gt;&lt;integer&gt;12&lt;/integer&gt;
              &lt;key&gt;Play Date&lt;/key&gt;&lt;integer&gt;3321087305&lt;/integer&gt;
              &lt;key&gt;Play Date UTC&lt;/key&gt;&lt;date&gt;2009-03-28T10:15:05Z&lt;/date&gt;
              &lt;key&gt;Rating&lt;/key&gt;&lt;integer&gt;80&lt;/integer&gt;
              &lt;key&gt;Album Rating&lt;/key&gt;&lt;integer&gt;80&lt;/integer&gt;
              &lt;key&gt;Album Rating Computed&lt;/key&gt;&lt;true/&gt;
              &lt;key&gt;Artwork Count&lt;/key&gt;&lt;integer&gt;1&lt;/integer&gt;
              &lt;key&gt;Persistent ID&lt;/key&gt;&lt;string&gt;E5B52C3DE807B7DC&lt;/string&gt;
              &lt;key&gt;Track Type&lt;/key&gt;&lt;string&gt;File&lt;/string&gt;
              &lt;key&gt;File Type&lt;/key&gt;&lt;integer&gt;1297106739&lt;/integer&gt;
              &lt;key&gt;Location&lt;/key&gt;&lt;string&gt;file://localhost/Users/ME/Music/iTunes/iTunes%20Media/Music/Ski/Jazzanova_%20The%20Remixes,%201997-2000/Fifths%20(Jazzanova%206%20Sickth%20Mix).mp3&lt;/string&gt;



You need to look out for the file:// bit of the xml. Here it is telling me that it is looking into /Users/ME/Music/, i.e. my home folder instead of my external hard disk.

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

sed is a nifty unix utility which you can use from Terminal. It can open a file, go through it line by line, change things on each line, and then put the result in another file. 


sed 's/file:\/\/localhost\/Users\/ME\/Music\/iTunes\/iTunes%20Media\//file:\/\/localhost\/Volumes\/HD1T\//'  &lt; /Users/ME/Desktop/iTunes\ Music\ Library.xml  &gt; /Users/ME/Music/iTunes/iTunes\ Music\ Library.xml



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  

&lt; /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  

&gt;  /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  

Now this is important - if you just start iTunes now, with the new .xml file there and no .itl file there, nothing will happen. iTunes will ignore the xml file, and just reset to an empty library. But if iTunes finds a broken .itl file, it will use the .xml file we just fiddled with to recreate the .itl file. The easiest way to create a broken .itl file is from terminal:


  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/