Move music library and update iTunes database

I’m doing some reorganization of my network shares. My music is saved on the server under its own share, “Music”. In the new scheme, I want the music folder to be located in a subfolder in the share “Multimedia”. This poses a small problem: I have to update iTunes to recognize the new file locations. I’ve got iTunes 10.6.3 on OS X Mountain Lion 10.8.1.

Edit iTunes Music Library.xml

The simple solution is to modify the Location values in the iTunes Music Library.xml file, mangle the iTunes Library.itl file, then open iTunes. iTunes will then rebuild the database file based on the xml (the .itl file is the active database file, the .xml file is regenerated based on the .itl database).  To find and replace all the locations I tried this:

cat ~/Music/iTunes/iTunes Music Library.xml | perl -pe 's//Volumes/Music///Volumes/Multimedia/music//i' > itunes.xml

Then quickly checked to see if I was missing any other locations:

cat itunes.xml | grep "Location" | grep -v "/Volumes/Multimedia/music"

Then erase iTunes Library.itl, replace iTunes Music Library.xml with this new copy (making backups of the originals first, of course).

An unfortunate side effect of rebuilding the .itl based on the xml: the Date Added values for the entire library are reset (probably other values are reset as well). I wanted to move my library files and keep all the metadata intact.

Edit iTunes Library.itl

So, instead of editing the xml file, what about editing the itl file? Unfortunately, the .itl file is a proprietary format binary file. Luckily, there are some who have tinkered with the file in order to edit .itl database entries. Enter Tools for iTunes Libraries (titl): excellent! I cloned the mercurial repository, built the code and tried to move some files:

$ hg clone https://code.google.com/p/titl/ titl
$ cd titl
$ mvn verify
$ java -Xmx512m -XX:MaxPermSize=256m -jar titl-core/target/titl-core-0.3-SNAPSHOT.jar MoveMusic --use-urls ~/Music/iTunes/iTunes Library.itl "file://localhost/Volumes/Music" "file://localhost/Volumes/Multimedia/music"

That resulted in a Exception in thread "main" java.io.EOFException, the exact same issue as this one. Downloaded the patch file that the user thankfully uploaded, applied the patch to the code, and tried again (disabling the now broken unit tests with -Dmaven.test.skip=true): success! Excellent!

Final step: rename the iTunes Library.itl.processed file to iTunes Library.itl (making backup first of the original file of course). iTunes works as expected, music files are found, play count still there, “last added” dates still there.

Not that I use iTunes very often (or really at all) anymore to play music. Spotify is the scheisse these days! 😉

Updated 2011-12-16: Uploaded the patched + compiled jar (for those of you who want it)

45 comments
  1. Hi,
    very interesting I am trying to exactly the same and I’ve come to a stop due to the itl file. Would it be possible for you to edit my file for me? Can I send you a dropbox link were to download it?

    1. Hi, I’ve replied to your email address you provided–I can give it a try, see if I have any luck modifying the paths for you…

      1. Mail sent Thanks!!

  2. it DID work perfectly!! no need for me to consolidate from Windows to switch to Mac so I can keep the folder structure I have and which I don’t want to loose… thanks again a ton!!! PS SuperSync is very hand to check at the end if there are any missing tracks since it compares two XML libraries if you u want

    Thanks!!!!

    1. Glad it worked! 🙂

      1. For the record on iTunes 11.0.1

    2. I’m having a bit of trouble getting this to work on my iTunes 11 on Win7 64-bit… the Google Code project doesn’t seem to have any downloads available? Where exactly do I download this program; is it an exe or do I need to download some other programs with which to run the code? Thank you in advance for any help! 🙂

      1. Hi!

        The “Tools for iTunes Libraries” program must be compiled first, then run (it’s a Java program). Furthermore (I haven’t checked the code recently, it might already be fixed), the code needs to be patched to fix a problem. So you’ll need to check out the code from the repository, patch it, compile it, then you can run it. All this assuming you have the Java SDK installed and build tools (java, javac compiler, maven, mercurial, etc). If you don’t want to patch + compile the code yourself, I have uploaded it as a jar file to the blog post (see the very end of the post), but this will still of course require that you have Java installed on your computer in order to run:
        [sourcecode gutter=”false” light=”true” wraplines=”false” highlight=”1″ language=””]
        $ java -Xmx512m -XX:MaxPermSize=256m -jar titl-core-0.3-SNAPSHOT.jar MoveMusic –use-urls ~/Music/iTunes/iTunes Library.itl "file://localhost/Volumes/Music" "file://localhost/Volumes/Multimedia/music"
        [/sourcecode]

  3. Hi David,

    Thanks so much for the detailed walkthru and for sharing your patched version.

    Do you know if MoveMusic still works on iTunes 11 itl files? When running it to move from a volume named “Old” to a volume named “New”, I received the following error:


    $ java -Xmx512m -XX:MaxPermSize=256m -jar ./titl-core-0.3-SNAPSHOT.jar MoveMusic --use-urls ./iTunes Library.itl "file://localhost/Volumes/Old/Music" "file://localhost/Volumes/New/Music"
    Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.kafsemo.titl.tools.Main.main(Main.java:42)
    Caused by: java.util.zip.ZipException: oversubscribed dynamic bit lengths tree
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:147)
    at org.kafsemo.titl.Hdfm.inflate(Hdfm.java:226)
    at org.kafsemo.titl.Hdfm.read(Hdfm.java:109)
    at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:52)
    at org.kafsemo.titl.tools.MoveMusic.main(MoveMusic.java:167)
    ... 5 more

    While digging around for more info on the “iTunes Library.itl” file format, I stumbled onto this: http://code.google.com/p/picardplugins/wiki/LibraryFile

    “I read that the binary file format documentation isn’t available even to other teams at Apple, and that, at least once, they deliberately made changes just to break any code that was parsing the file so they could tell other (Apple) teams to stop doing that and use the XML file instead.”

    Given that titl apparently hasn’t been updated since the release of iTunes 11, perhaps the format has changed again?

    On a side note, one piece of info that “iTunes Library.itl” will happily divulge is the version of iTunes used to create it (found with Hex Fiend at offset 17).

    1. I just did a test with my latest library file (v11.0.1) and I’m not getting the ZipException you describe. I thought it might have something to do with my library being an “upgrade” from a previous version, so I moved ~/Music/iTunes to ~/Music/iTunes.bak and opened iTunes, which subsequently created new v11.0.1 library files. I added a music album to this new library, and tried the MoveMusic command again: same result, no errors, no ZipException. Another user (see the other comments) has successfully moved his v11 library as well. Strange!

      I notice there are some old bug reports mentioning a ZipException: titl issue 20 and titl issue 15. I haven’t dug in the code to see how to change this…

      Hope this info helps, and good luck!
      ./david

      1. Thanks so much for taking the time to look into it, David!

        I tested the same “iTunes Library.itl” file (originally from iTunes 11 running under OS X 10.6) on OS X 10.7 and Windows XP; received the same error:
        java.util.zip.ZipException: oversubscribed dynamic bit lengths tree

        Then I tested a different “iTunes Library.itl” file (from iTunes 10 running under OS X 10.7) and it worked just fine.

        Thanks again!

  4. Hi,
    I’m not savvy enough to use these tools to edit my itl file, was hoping you could make changes for me? I’m just trying to direct my library to a shared network drive now, I’d rather not lose my “date added” data using my XML (Windows 7, itunes 10.7).
    Thanks!

    1. Hi,

      Sure… if you want to send me your .itl file (zip it up first, then DropBox or email) I can give it a try. Most importantly, you need to tell me the two file location roots that will be find-replaced. Check your .xml file and give me the exact old location root and then new location root, look for the Location string value, e.g.:
      <key>Location</key><string>file://localhost/Volumes/Multimedia/music/Daft%20Punk/Human%20After%20All/Technologic.mp3</string>. From that example the “root” would be file://localhost/Volumes/Multimedia/music/.

      If you don’t have a way to easily share the file (DropBox or similar), I can ping you at the email address you provided and then you can mail me back with the compressed .itl file.

      ./david

      1. Yeah, please shoot me an email, I greatly appreciate it.

      2. Any chance I could take advantage of this same offer for assistance? My dropbox account is associated with this email address. Many thanks if you’re able to assist!

        1. Hi, yes! Sorry it took so long for the reply. I’ll send you an email!

  5. Oh thank goodness, this topic is still live! I’ve been wrestling with iTunes to get my library ported from my old XP-based pc to my Windows 7 laptop. As the folder structure is different in Win7, I was just going to find and replace all of the incorrect path information in the xml file, but as you pointed out, this doesn’t work anymore.

    I really found your post helpful, I went and got TITL, ran it (after some errors in my parameters) then held my breath in anticipation and for good luck. Alas, none came as I’m getting a FileNotFoundException being thrown over what looks like it should be a temp file created within the program (C:tmpiTunes Library_noCrypt_pre.itl). Could it be that there’s a permission issue that’s not being flagged when the file creation is attempted, and because it can’t be created, it then fails on write? In any case, have you any idea how to fix it?!

    Thank you again for writing such a helpful post, I find that these can read one of three ways:
    1) The helpful one : hard to find at times, especially on stack overflow.
    2) The crazy-dedicated-techie one : You need to learn a new language, install a load of software, do it on the 3rd night of the first full moon of the new Chinese calendar in the year of the Dragon (while hopping on one foot)
    3) The one that is verbatim from an API/software manual : Not helpful as the source material is usually the first port anyway.
    [Optional 4th : The post sparked by someone seeking help : Either it’s dead after two replies, it’s too niche to be useful, or it devolves into attacking the poor poster]

    You definitely fall into category 1!

    1. Thanks for the kind words, and I’m glad I could be of at least partial assistance!

      As far as your FileNotFoundException, could it have something to do with the filename containing a space character? It’s a shot in the dark, but perhaps try renaming your “iTunes Library.itl” to something without a space and try again (I had no problems with filenames containing spaces, but I ran this on OSX, not Windows…)?

      Good luck!

  6. I just tried compiling the latest version of titl-core-0.3-SNAPSHOT.zip which I achieved successfully. However I got a nasty java.util.zip.ZipException just like some others on here have reported.

    I just found an even easier way to achieve the same without using titl-core (well on a Mac at least). Steps are:

    1) Copy your old music to the new location say /Volumes/DirectoryB on Mac OSX
    2) Go to the directory where your existing music is stored (in my case this was /Users/Shared/Music/iTunes)
    3) Rename the directory /Users/Shared/Music/iTunes to something like /Users/Shared/Music/iTunesOLD
    4) Create a symbolic link in /Users/Shared/Music/ to the new location of the music by running a command like:

    ln -s iTunes /Volumes/DirectoryB

    5) Restart iTunes. Whenever you play a song, iTunes will follow the symbolic link and get the file from DirectoryB. In fact if you right click on the file playing and click Get Info it will even look like it’s updated its itl file to point at this location but alas I believe the iTunes Music Library.xml file will always still have the old file name. However as long as you don’t remove the symbolic link, this should still work!
    6) You can now remove your old music files by running rm -rf /Users/Shared/Music/iTunesOLD

    Hope that helps!

    1. Thanks for the tip!

  7. Hi David! Thanks a lot for this usefull post, but I’m not good with that kind of things… Could you edit my “iTunes Library.itl” for me please? You’ll save 10 years of “last added”… You can shoot me an e-mail…

    1. Hi, sorry it took so long for the reply. I’ll send you an email!

  8. “The simple solution is to modify the Location values in the iTunes Music Library.xml file, mangle the iTunes Library.itl file, then open iTunes. iTunes will then rebuild the database file based on the xml”

    This didn’t work for me with Windows XP and iTunes 11; iTunes kept overwriting the XML with a new blank one every time.

    What did work was deleting the XML and ITL files, opening iTunes, and then clicking File > Library > Import Playlist… and selecting my edited XML file.

    Thanks again for the instructions and for maintaining this thread, David!

  9. I finally found out how to download the titl sources and to apply the patch you mentioned earlier in Eclipse.

    First I had to create C:\tmp or the Java application would fail prematurely.

    The .itl file gets decompressed nicely, however the job never completes. Here’s the error message I see:

    D:\Users\Olivier\workspace\titl>java -Xmx1024m -cp bin org.kafsemo.titl.tools.MoveMusic "D:\Users\Olivier\Music\iTunes\iTunes Library.itl" "C:\Users" "D:\Users"
    
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
            at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:111)
            at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:60)
            at org.kafsemo.titl.tools.MoveMusic.main(MoveMusic.java:167)
    

    For what it’s worth, when I try to export the ratings, I get the following error message:

    D:\Users\Olivier\workspace\titl>java -cp bin org.kafsemo.titl.tools.ExportRating
    s "D:\Users\Olivier\Music\iTunes\iTunes Library.itl"
    Exception in thread "main" org.kafsemo.titl.ItlException: Unhandled type: msdh
            at org.kafsemo.titl.ParseLibrary.drain(ParseLibrary.java:501)
            at org.kafsemo.titl.ParseLibrary.parse(ParseLibrary.java:95)
            at org.kafsemo.titl.ParseLibrary.parse(ParseLibrary.java:81)
            at org.kafsemo.titl.tools.ExportRatings.main(ExportRatings.java:44)
    

    So it appears that in recent iTunes versions a new “msdh” block is added.

    Who could help me?

    1. Hi!
      Hmm… the first issue you should hopefully be able to solve by increasing the heapspace. Try increasing it to 2GB, e.g. -Xmx2048m

      The second issue, since you mentioned you have Eclipse I recommend you try adding some code and recompiling. In the else-if statement on lines 489-494 in ParseLibrary (at least those are the line numbers in my version of the class), try adding an additional or-clause for the new unhandled type (which will skip over this block):

                  else if (type.equals("hghm") || type.equals("halm") || type.equals("hilm") || type.equals("htlm") || type.equals("hplm")
                          || type.equals("hiim") || type.equals("msdh"))
                  {
                      di.skipBytes(length - consumed);
                      consumed = length;
                  }
      

      Try re-running the code and then add any additional unhandled types as you discover them.

      Good luck!

      1. Thank you for your reply!

        So I had to ask for 4GB of shared memory (-Xms4096m) to make it run on my computer.

        There is still an EOF exception:

        Exception in thread "main" java.io.EOFException
        at java.io.DataInputStream.readFully(Unknown Source)
        at java.io.DataInputStream.readFully(Unknown Source)
        at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:113)
        at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:60)
        at org.kafsemo.titl.tools.MoveMusic.main(MoveMusic.java:167)

        In C:\tmp I see that several paths seem to have been modified from C:\Users to D: <Users however the ITL file is not modified (maybe due to the Java EOF Exception?)

        Also, while looking at the temp ITL file with a hex editor I see that some entries remain with C:\Users – see the snippet below:


        mith { ... }

        mhoh
        /GKalimba

        mhoh
        2Mr. Scruff

        mhoh
        2Mr. Scruff

        mhoh
        AA. Carthy and A. Kingslow

        mhoh
        2Ninja Tuna

        mhoh
        2Electronic

        mhoh
        7MPEG audio file

        mhoh
        :Ninja Tune Records

        mhoh
        }UC:\\Users\\Olivier\\Music\\iTunes\\iTunes Media\\Music\\Mr. Scruff\\Ninja Tuna\1 Kalimba.mp3

        mhoh
        Anfile://localhost/D:/Users/Olivier/Music/iTunes/iTunes%20Media/Music/Mr.%20Scruff/Ninja%20Tuna/01%20Kalimba.mp3

        mith { ... }

  10. Hello David. I don’t know how to use the code to edit my files. I was wondering if you could help me and edit my files as you have done for others. I have my xml and itl files ready on dropbox. Thanks.

    1. Sorry it took so long for the reply. I’ll send you an email!

  11. Oops – the hex dump snippet was cleaned up by the CMS. Here’s another version:

    mith { ... }

    mhoh
    [x18][x00][x00][x00]/[x00][x00][x00][x02][x00][x00][x00]G[x00][x00][x00][x00][x00][x00][x00][x03][x00][x00][x00][x07][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00]Kalimba

    mhoh
    [x18][x00][x00][x00]2[x00][x00][x00][x04][x00][x00][x00][x01][x00][x00][x00][x00][x00][x00][x00][x03][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00]Mr. Scruff

    mhoh
    [x18][x00][x00][x00]2[x00][x00][x00][x1b][x00][x00][x00][x01][x00][x00][x00][x00][x00][x00][x00][x03][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00]Mr. Scruff

    mhoh
    [x18][x00][x00][x00]A[x00][x00][x00][x0c][x00][x00][x00][xc5][x03][x00][x00][x00][x00][x00][x00][x03][x00][x00][x00][x19][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00]A. Carthy and A. Kingslow

    mhoh
    [x18][x00][x00][x00]2[x00][x00][x00][x03][x00][x00][x00][x01][x00][x00][x00][x00][x00][x00][x00][x03][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00]Ninja Tuna

    mhoh
    [x18][x00][x00][x00]2[x00][x00][x00][x05][x00][x00][x00][x01][x00][x00][x00][x00][x00][x00][x00][x03][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00]Electronic

    mhoh
    [x18][x00][x00][x00]7[x00][x00][x00][x06][x00][x00][x00][x01][x00][x00][x00][x00][x00][x00][x00][x03][x00][x00][x00][x0f][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00]MPEG audio file

    mhoh
    [x18][x00][x00][x00]:[x00][x00][x00][x08][x00][x00][x00][x01][x00][x00][x00][x00][x00][x00][x00][x03][x00][x00][x00][x12][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00]Ninja Tune Records

    mhoh
    [x18][x00][x00][x00]}[x00][x00][x00][x00][x00][x00][x01][x00][x00][x00][x00][x00][x00][x00][x03][x00][x00][x00]U[x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00]C:\\Users\\Olivier\\Music\\iTunes\\iTunes Media\\Music\\Mr. Scruff\\Ninja Tuna\1 Kalimba.mp3

    mhoh
    [x18][x00][x00][x00][x96][x00][x00][x00][x0b][x00][x00][x00]A[x01][x00][x00][x00][x00][x00][x00][x02][x00][x00][x00]n[x00][x00][x00][x00][x00][x00][x00][x00][x00][x00][x00]file://localhost/D:/Users/Olivier/Music/iTunes/iTunes%20Media/Music/Mr.%20Scruff/Ninja%20Tuna/01%20Kalimba.mp3

    mith { ... }

  12. Okay, I’m onto something.

    So Apple uses some sort of TLV format for the ITL file:
    T = 4-byte type identifier
    L = 4-byte value length identifier
    V = value buffer with legnth of L bytes

    However, apparently the endianness can change.

    As a result, I see the type identifiers reversed (e.g. “msdh” instead of “hdsm”) as well as length identifiers overflowing.

    I quickly hacked a rudimentary TLV parser to check this. So that’s probably why I’m getting memory overflows.

    Hmmm… making this work in TITL will prove nontrivial I fear.

  13. Posting in reply to my own post.

    I managed to correct one parsing error due to incorrect parsing of the “hdsm” header.

    It appears that you must always parse the first 16 bytes 4 by 4 (b0 = bytes 0-3, b1 = bytes 4-7 etc):
    b0 = “hdsm” / “msdh” depending on “endianness”
    b1 = length OR dummy
    b2 = dummy OR length
    b3 = hdsm_subtype

    If subtype == “04 00 00 00” (= decimal 4) then the header length is given in b2 instead of b1.

    So far I identified the following hdsm_subtypes in my library file (I always mention the header type as well as the preceding header type in order to see if there’s some more informaiton in there):

    $ grep "hdsm\]\s[3]" parse_tlv.log
    [???? > hdsm] 3 4 subtype = 10 00 00 00
    [hdfm > hdsm] 3 4 subtype = 0C 00 00 00
    [hohm > hdsm] 3 4 subtype = 09 00 00 00
    [hohm > hdsm] 3 4 subtype = 0B 00 00 00
    [hohm > hdsm] 3 4 subtype = 01 00 00 00
    [hohm > hdsm] 3 4 subtype = 0D 00 00 00
    [htlm > hdsm] 3 4 subtype = 14 00 00 00
    [hohm > hdsm] 3 4 subtype = 02 00 00 00
    [hptm > hdsm] 3 4 subtype = 0E 00 00 00
    [hplm > hdsm] 3 4 subtype = 15 00 00 00
    [hohm > hdsm] 3 4 subtype = 04 00 00 00
    [hdsm > hdsm] 3 4 subtype = 0F 00 00 00

    Please note that in my (i64) examples, the first byte in a 4-byte word is always the least significant byte. In my DumpTLV routines I rewrite the byte order to accommodate the existing decoding if available (eventually).

  14. I completely rewrote the iTunes library (ITL) file decoding, by taking care of endianness and by analyzing the structure of the ITL file.

    My findings are that each header type has a fixed 4-byte “length” identifier followed by a header block length field. The fixed “length” identifier fields are:

    TYPE WORD1 LENGTH=
    haim 88 (b4-b7)
    halm 92 (b4-b7)
    hdfm 144 (b4-b7)
    hdsm 96 (b4-b7)
    96 (b8-b11)
    hghm 268 (b4-b7)
    hiim 80 (b4-b7)
    hilm 100 (b4-b7)
    hohm 24 (b8-b11)
    hpim 3420 (b4-b7)
    hplm 92 (b4-b7)
    hpsm 48 (b4-b7)
    hptm 84 (b4-b7)
    hqim 220 (b4-b7)
    hqlm 112 (b4-b7)
    hrlm 92 (b4-b7)
    hrpm 24 (b4-b7)
    hslm 44 (b4-b7)
    htim 736 (b4-b7)
    htlm 92 (b4-b7)

    I can also reconstruct the header block hierarchy (tree).

    How should I proceed?

    1. Your analysis is amazing! You’ve certainly looked at the code much more in depth than I have. If you’re just asking for general help about how to write code that parses those types, I’m not certain I’d be of much help… perhaps try contacting one of the developers on the project, they might be able to help you with your questions? http://code.google.com/p/titl/source/checkout (once again, I’m not a developer on the project, just a lowly user)

  15. Hello David,

    I have scoured the internet today and what you describe here is exactly what I am looking for. I simply need to edit the .itl file to change the location of my music from my C:/ to my S:/

    I have made the changes in iTunes Music Library.xml but as you say, it needs to be rebuilt from the .itl file

    I am having a very hard time figuring out how to run this tool mentioned here — I am on Windows 7. Is there any possible chance you could edit my .itl file for me? I would be indebted to you.

    Could I send you my updated iTunes Music Library.xml file, would that help? Again I am only needing to change the location of my music from C:/Users/Pat to S:/Users/Pat

    Otherwise if you could give me any tips on how to run this, I would greatly appreciate it.

    Thanks!!

    1. Or perhaps I could change my drive path back to C:/… that might actually be a much better idea. I will start working on that in the meantime, perhaps that is a better idea for me after all…

  16. I created c:\tmp and received the following error:

    C:\Users\Jake\titl>java -Xmx512m -XX:MaxPermSize=256m -jar titl-core-0.3-SNAPSHO
    T.jar MoveMusic "C:\Users\Jake\titl\iTunes Library.itl" "D:\My Documents\Music\M
    P3s" "C:\Users\Jake\Music\mp3s"
    Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=256m; support wa
    s removed in 8.0
    Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.kafsemo.titl.tools.Main.main(Main.java:42)
    Caused by: java.lang.OutOfMemoryError: Java heap space
    at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:111)
    at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:60)
    at org.kafsemo.titl.tools.MoveMusic.main(MoveMusic.java:167)
    ... 5 more

    Any help would be greatly, greatly appreciated! My iTunes library is 9.8 MB if that’s important.

    1. Hi, try upping the -Xmx and/or -XX:MaxPermSize arguments in the command. For example, -Xmx1024m (which would allocate up to 1GB max memory to the java heap). If you get a OutOfMemoryError for PermGenSpace, then increase the -XX:MaxPermSize argument. Good luck!

      1. Thanks for the reply. I tried upping the -Xmx to 1024 and got the same error. Tried upping it to 2048 and got a different error:

        C:\Users\Jake\titl>java -Xmx1024m -jar titl-core-0.3-SNAPSHOT.jar MoveMusic "C:\
        Users\Jake\titl\iTunes Library.itl" "D:\My Documents\Music\MP3s" "C:\Users\Jake\
        Music\mp3s"
        Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.kafsemo.titl.tools.Main.main(Main.java:42)
        Caused by: java.lang.OutOfMemoryError: Java heap space
        at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:111)
        at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:60)
        at org.kafsemo.titl.tools.MoveMusic.main(MoveMusic.java:167)
        ... 5 more

        C:\Users\Jake\titl>
        C:\Users\Jake\titl>java -Xmx2048m -jar titl-core-0.3-SNAPSHOT.jar MoveMusic "C:\
        Users\Jake\titl\iTunes Library.itl" "D:\My Documents\Music\MP3s" "C:\Users\Jake\
        Music\mp3s"
        Error occurred during initialization of VM
        Could not reserve enough space for 2097152KB object heap

        Do you think I could upload my ITL to dropbox? I see you’ve done that for others, and I don’t want to abuse your hospitality, but I’m getting kind of desperate here!

      2. OK, I tried it again on a different computer. The first one was a 32-bit Vista OS with 3GB RAM. The second one was a 64-bit Windows 7 OS with 8 GM RAM, and this time I was able to up the Xmx to 4096, but now I get this error:

        C:\titl>java -Xmx4096m -jar titl-core-0.3-SNAPSHOT.jar MoveMusic "C:\titl\iTunes
        Library.itl" "D:\My Documents\Music\MP3s" "C:\Users\Jake\Music\mp3s"
        Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.kafsemo.titl.tools.Main.main(Main.java:42)
        Caused by: java.io.EOFException
        at java.io.DataInputStream.readFully(Unknown Source)
        at java.io.DataInputStream.readFully(Unknown Source)
        at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:113)
        at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:60)
        at org.kafsemo.titl.tools.MoveMusic.main(MoveMusic.java:167)
        ... 5 more

        Please help! I’m losing my mind!

        1. Hi! Hmmm… not sure what’s going on, it could be that the latest iTunes library format is unreadable by the titl tool. Another reader commented about modifying the code to read certain parts of the library. It looks like the author of titl has been making some recent changes (and switched from Mercurial to git), so maybe cloning the latest source and building might help. If you want I can try to convert your file for you, it’s worth a shot! I’ll send you an email.

          1. Hi Jake,

            crap… looks like I get the same error as you do 🙁


            $ java -Xmx4096m -XX:MaxPermSize=512m -jar titl-core/target/titl-core-0.3-SNAPSHOT.jar MoveMusic --use-urls ~/Downloads/iTunes\ Library.itl "D:\My Documents\Music\MP3s" "C:\Users\Jake\Music\mp3s"
            Exception in thread "main" java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:606)
            at org.kafsemo.titl.tools.Main.main(Main.java:42)
            Caused by: java.io.EOFException
            at java.io.DataInputStream.readFully(DataInputStream.java:197)
            at java.io.DataInputStream.readFully(DataInputStream.java:169)
            at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:113)
            at org.kafsemo.titl.ProcessLibrary.process(ProcessLibrary.java:60)
            at org.kafsemo.titl.tools.MoveMusic.main(MoveMusic.java:167)
            ... 5 more

            I tried cloning the latest source, and I get EOFException using the latest code as well. I’m not sure if the titl-code maintainer has some plans to fix compatibility issues with the latest iTunes format (or if that is even the problem here), worth a shot reading up on the bugs/issues: https://code.google.com/p/titl/issues/list

            I think it’s possibly related to a change in a recent version of iTunes (I originally moved my library a few years/versions back). Another reader commented and make quite some progress debugging a few months ago, getting the same exception we get: https://david.gyttja.com/2012/09/08/move-music-library-and-update-itunes-database/#comment-445

            To solve your problem now: perhaps create some kind of symbolic links (or aliases/shortcuts/whatever-they’re-called in Windows) for the old directory structure? Then maybe you can use the built-in iTunes /keep iTunes folder organized function? That might help you move things? Here’s Apple’s less-than-optimal solution, as your library will get reorganized: http://support.apple.com/kb/HT1364?viewlocale=en_US&locale=en_US

            Sorry and good luck!
            ./david

          2. Thanks for trying, David. I appreciate it. I’ve been messing around with the “FindTracks” VB script from samsoft, and I think with some hacking and a bit of work I’ll be able to find the majority of my collection.

            I just wish that Apple would expose the prior location via the API rather than returning .Location as an empty string. We know the prior location is in the database since we can see it in the “Where” field via the UI. So frustrating!

  17. Very good info. Lucky me I found your blog by chance
    (stumbleupon). I have saved it for later!

  18. Since the script is not working anymore, I ended up importing the old itl in iTunes, so all the paths were obviously broken. But then I let iTunes find the missing files (9000 of them), just by clicking one and browsing to the correct location. It took five minutes, but all the (!) icons disappeared one by one, and all the correct locations were set 🙂
    You should try this if you plan to move your files ! It even worked from Win7 to OSX (which I did).

    1. great! thanks for that tip!

Leave a Reply

Your email address will not be published. Required fields are marked *