Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use two iTunes libraries and one Music folder Apps
Suppose you are in a household with two Macs. Each person has a copy of iTunes installed. They both want access to the same music directory, but they both want it to be part of their own library. iTunes already makes it easy to share your music over a LAN, which is nice up to a point, but doesn't give you much flexibility: you can't assign star ratings to someone else's music, make playlists, or load up an iPod with it. What you really want is for all that music to be yours (and all your music to be similarly available to your cohabitant).

Here's the recipe. I'll assume you have a LAN set up already.
  1. On each computer, go into System Preferences: Sharing: Services, and enable "Remote Apple Events."

  2. Designate one computer as the "music host;" the other will be the "music client."

  3. On the client, connect to the host, and mount the hard drive on the host that contains the iTunes music folder. Go into iTunes Preferences: Advanced on the client and set it to use the same folder as the iTunes music folder as the host (the one on the host's computer).

  4. In the interest of good file management, you probably want to go into iTunes Preferences: Advanced on the host and enable "Keep iTunes Music folder organized" and "Copy files to iTunes Music folder when adding to library." However, on the client machine, I think you will need to disable these (otherwise multiple computers will contend over where and how the files should be organized). If the client already has music files stored locally, relocate those files to the host, and remove them from the client. Add those tracks to the library of the host computer manually.

  5. Find and remove the files "iTunes Music Library" and "iTunes Music Library.xml" (or create an archive of them) from the folder ~/Music/iTunes on the client machine. Manually add all the tracks on the host machine to the client's copy of iTunes by dragging them into the iTunes window. For very large collections, you should probably do this in chunks (iTunes seems to get confused otherwise). I added all the artists starting with A at once, then B, etc. Took a while, but it worked.

  6. Now both users have access to the same music directory, can make their own playlists, set their own ratings, load up their own iPod, etc. The problem is that the situation is static--if anyone adds a new track, things get out of sync, and only that user will have access to that track (without additional futzing).

  7. That is where this mystical-magical AppleScript comes in. This was pretty much written by "deeg" (with some nudging from me) in the Applescript for iTunes forum at iPod Lounge. Copy this script and save it as "sync libraries" to the directory ~/Library/iTunes/Scripts (if you don't already have a Scripts folder there, create it). Relaunch iTunes, and it will be available under the Scripts menu. You can now run this script manually on each computer to update its library against the host. Better yet, use a timed macro (or cron job, which you can set up easily with Cronnix) to launch the script in the wee hours. This assumes that each computer will be turned on when the script executes.
Additional notes:
  • Assuming that different computers will have different user accounts, you will need to specify the other user's username and password in the "please enter the address" dialog that appears when first running the script. The URL format looks like this:
    eppc://username:password@machinename.local
    I'm not sure how to deal with spaces in the computer name (perhaps a backslash before the space); my machines all have one-word names; you can change the computer's name in System Preferences: Sharing.

  • Likewise, it should be possible to sync libraries between two user accounts on a single machine using the above format. This probably requires that both users are always logged in (using Fast User Switching).

  • This script only works for one host and one client. It should be possible to modify it to deal with multiple clients. I will leave that as an exercise for the reader.
[robg adds: I haven't tested this one...]
    •    
  • Currently 2.29 / 5
  You rated: 1 / 5 (7 votes cast)
 
[86,681 views]  

Use two iTunes libraries and one Music folder | 23 comments | Create New Account
Click here to return to the 'Use two iTunes libraries and one Music folder' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use two iTunes libraries and one Music folder
Authored by: bjmorgan on Mar 25, '05 11:32:23AM

I used to do this years ago before I bought my iPod. I didn't have much hard drive space to spare, but had access to a personal & private account on an Appleshare File Server where I stowed my music library. All I had to do was Login to the server at startup.

After I bought the iPod there was no need to hog up space on the server. Now, I just keep my library on the iPod and not locally, and all I have to concern myself with is making backups of the music on my iPod. Thank goodnes for DVD-R.



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: bjmorgan on Mar 25, '05 11:35:51AM

I used to do this years ago before I bought my iPod. I didn't have much hard drive space to spare, but had access to a personal & private account on an Appleshare File Server where I stowed my music library. All I had to do was Login to the server at startup.

After I bought the iPod there was no need to hog up space on the server. Now, I just keep my library on the iPod and not locally, and all I have to concern myself with is making backups of the music on my iPod. Thank goodnes for DVD-R.



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: wilder212 on Mar 25, '05 11:56:58AM

The heck with manually importing each song or group of songs. Once you've completed the setup on each computer, go under import (under File) and import the Host iTunes Music Library.xml file. It'll bring all your songs in with no problem. I had 1500 songs and it did it in under a minute.
BTW - great hint and this is going to help me a lot!!



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: macburner on Sep 06, '05 06:46:23AM

what if the music is stored on an ethernet disk? i've 2 macs: the powerbook's library updates correctly, also because the music is added from the cd player of the PB. but when i'm in the studio, where i've the other mac, it keeps me to show a limited music library, not updated...
do you have suggestions?
thank you,



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: fil_dawg on Mar 25, '05 01:06:42PM

Awesome hint!! Thank you - I've been working on something like this for a while.



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: marbs on Mar 27, '05 11:53:11AM

Please, if anyone knows: Will this work if only one of these machines is a mac? We have a Mac server with mac and pc clients.



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: joestalin on Mar 28, '05 11:23:48AM

Unless there has been a great disturbance in the force, this <em>will not work</em> with non-Mac computers. It relies on Applescript and AppleEvents, and unless someone has written an amazing, transparent Applescript-to-whatever-works-on-Windows translation tool, there is no way for Win-iTunes to send or receive AppleEvents, or to run Applescript.



[ Reply to This | # ]
Space in the computer name
Authored by: jecwobble on Mar 25, '05 02:15:35PM
Without actually testing, I would presume that you could use the standard %20 for spaces in a URL. For example
eppc://username:password@machine%20name.local


[ Reply to This | # ]
What about multiple users
Authored by: SOX on Mar 25, '05 05:05:45PM

How do you do this for multiple users on one machine? YOu can of course share the library but then when a users adds a song the others plists get out of sync. How do you keep multiple users sharing a tunes library in sync as they asynchonously add music.



[ Reply to This | # ]
What about multiple users
Authored by: joestalin on Mar 26, '05 09:18:17AM

I haven't tried this, but I address that scenario in my notes above.



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: Dephex Twin on Mar 26, '05 01:17:41PM

I do this same thing, only instead of having two separate sets of library information, I just made aliases to "iTunes 4 Music Library" and "iTunes Music Library.xml" on my client machine. That way, when iTunes launches, it is automatically exactly the same as the host without manually updating. Also, I can copy music into my library on either machine and it works fine.

You just can't be running iTunes on these two machines at the same time (it just won't launch on the 2nd computer, nothing bad happens).

Also, since my client is a laptop and I am sometimes not going to be at home on this network, I have an AppleScript program that I click to launch iTunes, that checks to see if it can connect to the host library, and if it can't, it launches a local library.

---
"Knicks suck, Yankees suck, Mets suck..."
"...Krypton sucks"



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: jocknerd on Mar 26, '05 09:13:40PM

This is one area Apple deserves a failing grade on. I can't believe they never thought that multiple users on one computer might want to actually share the same music. I guess this is where DRM really starts to bite you in the ass. If there's no DRM, you don't have to worry about who owns the song so it could be stored anywhere. DRM makes everything more difficult than it should be.

Am I the only one who is sick of these iPod shuffle commercials every 5 minutes? Apple, could you please make one commercial showing OS X?

---
OS X 10.2
Apple Styling, Unix Power



[ Reply to This | # ]
iPod adverts
Authored by: richardthomas78 on Mar 27, '05 03:01:22AM

A bit off topic but I think this iPod halo thing is worth investing in - owning an iPod got me hooked on all things Apple, and now I'm visiting macosxhints and typing this on a Mac mini ;) Back on topic, this tip works great on my wife's old laptop with a miniature HD (and thanks to the iPod, we're saving up for a nice new iBook to replace it!)



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: ozzyrules on Mar 26, '05 11:06:16PM

I have been doing something very similar for several years. I have all the music on a separate internal drive. I use SharePoints to set the desired permissions. Having it on a separate volume allows the path to the music to be the same, which comes in handy for xml song list exports/imports between computers. No apple events sharing is necessary. Each computer shares the music yet has independent libraries. As with the above hint, syncing them becomes an issue. That is where the xml export/import song list comes in handy.



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: zgafford on Mar 28, '05 05:29:03PM

So my girlfriend just picked up a laptop with XP on it. I have an iMac G5 and all our music is on an external hard drive connected to the mac. Is there are way to share the library between OS X and XP so we can both listen at the same time?



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: nintwala on Sep 02, '05 11:32:56PM

Did you or anyone have any luck with this question? about sharing a library between a Mac OS X and Windows XP?

Please let me know, I am trying to do the same thing.

Thanks...



[ Reply to This | # ]
Use two iTunes libraries and one Music folder
Authored by: edmechem on Nov 09, '05 01:11:39PM

You *should* be able to just use iTunes' built-in sharing feature for this. Or am I not understanding the question correctly?



[ Reply to This | # ]
A different way to share a common library on a NFS network share
Authored by: babbage on Mar 29, '05 11:18:48PM

I use a modified (and simplified) version of this , but it's highly dependent on the particulars of the network setup here: user accounts are centrally managed via NIS on a Linux server, various directories are mounted at boot time via NFS, and so anyone can log into any computer and have the same working environment whereever they go on the network. (You can get similar results in other ways -- AFP or SMB(samba) shares, per-user shares rather than system-wide ones, etc -- but the setup I'm describing is typical of predominantly Linux/Unix networks where the Macs have been added in to the pre-existing infrastructure.)

The hack is simple. I keep my iTunes library on one of the remote NFS mount points, but the configuration information for iTunes lives in my NFS mounted home directory. If anyone else would like to access my iTunes catalog, they already have direct access to the files, so all they need is the library database files. To do this, they remove their own iTunes configuration from their ~/Music/iTunes folder and add a symlink to mine:

mv ~/Music/iTunes ~/Music/iTunes.MOVED
ln -s ~babbage/Music/iTunes ~/Music/iTunes

That's it. Now, when they launch iTunes, they'll see my catalog. They won't be able to change anything, as the files belong to me and I don't have them set to allow group/world write access, but if we all trusted each other then we could do that. As it is now, they can all view but not change things, but that's mostly acceptable, as I try to keep the ID3 data well filled out so that you can search & shuffle however you like.

For the people that can't access the NFS shares like this -- that is to say, for the Windows users, who can only see their own home directories on our network -- there's still the fallback of iTunes's own sharing capabilities. This is fine, but for the people that take advantage of it, the other way we're doing is better... :-)

---

--
DO NOT LEAVE IT IS NOT REAL

[ Reply to This | # ]

Use two iTunes libraries and one Music folder
Authored by: jfaughnan on Nov 08, '05 02:01:28PM

Great tip. I submitted something similar but Rob pointed me here. This is better.

Only one addition. If both users are on the same machine, you can copy the iTunes Library database file to the new user and have them work with that as a starting point. So they get new lists, etc.

Also, for years I did something like this between XP and Mac, but it was a weird setup. Everything lived on the PC, including the Mac Library database file. There was a second database file on the PC too. I used to drag and drop the entire music library of 3000 tunes onto iTunes PC to create the PC database. The Mac client's iTunes folder had been replaced with a shortcut pointing to the files on the PC. Weird. Only problem was some character that was legal in one OS and not the other, I think either a hyphen or a slash or a colon.

---
--
John Faughnan
jfaughnan@spamcop.net
www.faughnan.com



[ Reply to This | # ]
Script may not work on one machine with FUS
Authored by: jfaughnan on Nov 09, '05 06:40:09PM

In the hint the author predicts the script will work with two users on one machine, so long as fast user switching is enabled. Alas, in my testing it did not (10.3.9).

I think the problem is that the script doesn't have a way to specify which user account should receive the apple events.

I'm going to send the script to a very savvy guy I know and see if he has some ideas.

---
--
John Faughnan
jfaughnan@spamcop.net
www.faughnan.com



[ Reply to This | # ]
Script may not work on one machine with FUS
Authored by: jfaughnan on Nov 09, '05 06:53:05PM

I found this (sorry, replying to my own posts!). So it looks doable!

Fast User Switching:

AppleEvents have been enhanced to support Fast User Switching.

Because of these changes it is now possible to send AppleEvents to applications running in any session, when the uid of the processes match. 'root', or uid 0 processes are allowed to send to any process in any session. Non-root processes can only target applications that match their uid.

To support remote AppleEvents in the multiple user scenarios, the typeApplicationURL definition has been enhanced with optional uid and pid parameters. Both uid and pid are optional. If not present, the active console user's applications will be targeted. As before, the username should be that of an admin user on the targeted machine.

eppc://[user[:password]@host/Application%20Name[?[uid=#]&[pid=#]

example:
eppc://zellers:wombat@jarpet.apple.com/Finder?uid=501&pid=31

---
--
John Faughnan
jfaughnan@spamcop.net
www.faughnan.com



[ Reply to This | # ]
Modified version for fast user switching environmnent
Authored by: jfaughnan on Nov 10, '05 09:17:23PM
This my first attempt at doing anything with Javascript. I've only begun to test it, but I think it's the right track. The problem with two users on one machine is that you have to tell AppleScript which user session to get the tracks from. The capability to do this was apparently introduced in 10.3 but it didn't work. In 10.4 its seems to work, but it's almost completely undocumented. In fact, this may be the first example of this that Google might index!

-- Faughnan modified 11/10/05
-- jfaughnan@spamcop.net
-- I know nothing of AppleScript and there's not much documentation (ie. none) on how to work with a FUS application. I'm indebted to Matt Neuberger for a key hint.
-- for this to work the shared iTunes library must be on a share the client can accces. I moved the library to a "public folder"
-- user running script must either have admin privileges on local machine or use an admin password on request
-- http://www.macosxhints.com/article.php?story=20050215130254540
-- http://developer.apple.com/releasenotes/Carbon/AppleEvents.html
-- eppc://username:password@machinename.local
-- http://lists.apple.com/archives/applescript-implementors/2005/Aug/msg00055.html
-- http://www.apple.com/applescript/releasenotes/110OSX.html

property theDateofLastSync : "" -- date of last sync
property theRemoteiTunes : "" -- application reference for iTunes in other user session

set theDateofLastSync to ((current date) - 1 * days)
-- set theRemoteiTunes to application "iTunes" of machine "eppc://adminusername:password@localhost/?uid=504&pid=1853" (uname and password NOT TESTED)

(*=== Main Run ===*)

if theDateofLastSync is "" then set theDateofLastSync to ((current date) - 1 * days) -- force date for first run
if theRemoteiTunes is "" then
	choose remote application
	set theRemoteiTunes to result
end if

-- chat with other machine
set GotsomeTracks to true
try
	with timeout of 30000 seconds
		-- tell application "iTunes" of machine theSharedTunes
		tell theRemoteiTunes
			using terms from application "iTunes"
				activate
				set theListofTracks to location of file tracks of library playlist 1 where date added > theDateofLastSync
				--	set NumTracks to count of items of theListofTracks
			end using terms from
		end tell
	end timeout
on error
	set GotsomeTracks to false
end try

-- back to this Machine
set SyncedOK to false
if GotsomeTracks then
	set SyncedOK to true
	set NumTracks to count of items of theListofTracks
	try
		tell application "iTunes" -- of machine theClientTunes
			if (NumTracks) is greater than 0 then
				repeat with alocation in theListofTracks
					add alocation to library playlist 1
				end repeat
			end if
		end tell
	on error
		set SyncedOK to false
	end try
end if

display dialog (NumTracks as text) & " tracks were added to the library."

---
--
John Faughnan
jfaughnan@spamcop.net
www.faughnan.com

[ Reply to This | # ]

Yet another method: drag and drop
Authored by: jfaughnan on Dec 11, '05 09:36:16PM

I've commented a few times on this hint, but I've just discovered another approach - a very simple one.

After adding new tunes to the 'master user', switch to the 'client user'. Then click on the folder containing all the music (needs to be accessible, I keep my music folder in my Public folder, so all have read-only access).

Drag and drop this folder to the left side of iTunes (client user session) - as if creating a Play List and adding tunes simultaneously.

iTunes compares the dropped folder to the current library and only adds references to new music. Then view by date added and add to playlists as desired. It's very fast.

---
--
John Faughnan
jfaughnan@spamcop.net
www.faughnan.com



[ Reply to This | # ]