Sharing your iTunes Library and Database files

This post has nothing to do with recording, but I figure if any readers are like me, they have large iTunes libraries that they want to share between computers on a home network. Yes you can just use iTunes built in sharing, but that requires iTunes to be running on both computers, and your actual library and associated files are still located on one computer. In my situation, I have my music files on my home server (which is running Fedora Linux), a macbook, and an iMac. I wanted my macbook and iMac to share the same iTunes library. I listen to most music from my macbook, but use my iMac to update my iPod. Confused yet? Yeah me too!

iTunes is a great app, but it has one main flaw in my eyes; it will not automatically update your library for you when new music files are added to the music library directory. In order to add files to your library you have to import (or drag) them into iTunes, then iTunes updates its library files and depending on if you have “copy files to iTunes folder” will organize and place the files in their respective directories.

You can change the location that iTunes places all of your music files under the Preferences > Advanced Tab > iTunes Music Folder Location. This does not however change where the iTunes database and xml files are located though; only where the music files are located. So technically you can change the Music Folder Location to a share on your music server, but you would still have two different library databases and xml files. These are the files that store all playlist and artist/song information; so even though you are sharing the same physical iTunes Music Folder, if you update from on computer the changes would not reflect when accessing your library from your other computer. Are you still with me?

iTunes does not allow you to change the location of your library database or xml files. iTunes will always look to your ~/Music/iTunes directory for them. So how do we trick iTunes into looking somewhere else for these files? Enter the Alias (not the TV show). An alias is this use, is basically a file that points to another location, but the app accessing this alias doesn’t know it is being directed to another location. Linux and Mac both allow you to create a file alias, Jackpot! I am not a Mac or Linux expert, but I figured I could just use an alias to redirect iTunes to my real library database and xml files, which will now be located on my server. Before you read any further, please backup your iTunes database and xml files!

Now that we know what to do, lets do it! I first organized my music samba share’s directory structure so that it was the same as my ~/Music directory. This is probably not required, because the Music Library Folder path is actually stored in one of the database or xml files, so iTunes knows where to look for the music files. Open iTunes and change the iTunes Music Folder Location to the share directory that your music folders are located in (in my case “mp3:iTunes:iTunes Music:”). I then copied my local “iTunes Music” and “iTunes Music Library.xml” files into my network share’s iTunes folder (remember I kept the same directory structure as my local Music directory, so for me “mp3/iTunes/”).
iTunes Music Folder Location

Now we need to create our Alias’s. In Finder go to your music network share and create an alias for both the “iTunes Music” and “iTunes Music Library.xml” files. To do this highlight the file and click command-L. This will create a file with the word “alias” at the end of its filename. Now copy these two new “alias” files back to your local ~/Music/iTunes folder. If you still had your old database files on your local machine, you will need to ditch them or just rename them. Now edit/rename the alias files you just copied, so that the word “alias” is not at the end of the file (you basically name them the same as the original files). Now you have alias files that iTunes will recognize (because they are named correctly), and that trick iTunes into finding your real database files located on your server share. BINGO!
MP3 Share

I then went to my other computer and repeated the same process by creating alias’s again and copying them to my local ~/Music/iTunes directory. I now have two computers that share the same library and library folders with each other, but my actual library is not on either one of the computers! Now no matter what computer I use to update my library, the library will automatically be updated when I open iTunes on the other computer. My library is located in one central location making backups simple, and I can update my iPod from my iMac with no problems.

If I confused you (I confused myself) then feel free to drop me a line and I will try and clear things up for you! One of the main problems you will probably have is with permissions. Make sure that users from both computers have write access to the server share, so that iTunes can edit those files.
And make sure you mount your music share before you fire up iTunes or else iTunes will crash because it cannot find your library files!

On a side note, my roommate has a PC and wanted to be able to access my library as well. I wasn’t going to allow him direct access to my library, but I did set up a Firefly mt-daapd server on my linux box so a shared library would be available to him at all times. Setting up a mt-daapd server is pretty easy, so I won’t go into details but check out the http://www.fireflymediaserver.org/ website for more info.

The ultimate iTunes setup? I think so!

Update!
After some more research I have found that it is possible to control where iTunes looks for the library database files. Option-Click on iTunes will bring up a dialog box allowing you to browse to your desired library location. Using my way and creating an alias still works, but this way we can cut out a step. I have not tried this built in option with different users on different computers, so I am not sure it works but it should.

Related Posts:

  • No Related Post

3 Responses to “Sharing your iTunes Library and Database files”

  1. Christian Says:

    Thanks a lot for this tutorial.
    One question came up while reading: What happens when the two instances of iTunes run simultaniously and edit the library at the same time? Do any conflicts arise? What is your experience?

    Thanks,
    Chris.

  2. Brett Says:

    Chris, unfortunately with this setup iTunes will crash if the other instance is running. I didn’t realize that while I was writing this post, but for me it really isn’t a big deal because I am usually on one computer or the other. Not sure there is an easy work around for this because you would be basically writing to the library file from two different places at the same time. Maybe if you set up two different files, and somehow scheduled one to update the other it may work. But again this would be difficult because how would you know which one to update?

  3. Christian Says:

    Ok, thanks. I had this feeling that there might be a problem :-)
    But I found a way to synchronize two iTunes libraries on two Macs using a single music-file network-storage:
    http://dougscripts.com/itunes/scripts/scripts07.php?page=1#listnotadded
    If someone adds music files to the library at Mac A, the other one has to run this script on Mac B from time to time to get the list of added files.

    Works for me, maybe also for someone else reading your post.

    Tnanks again,
    Chris

Leave a Reply

Search

Categories

Archives

Good Reading