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

Share a music/photo hard drive between two systems System
I store all my photos (iPhoto) and music (iTunes) on an external FireWire drive. Normally the drive is attached to my iMac, but when I travel, I take the external hard drive and hook it up to my laptop. I want to have my iTunes work whether or not the drive is attached, and have it work automatically.

The quick summary of my solution is:
  • Move ~/Music/iTunes to ~/Music/iTunes.local
  • Move ~/Pictures/iPhoto Library to ~/Pictures/iPhoto_Library.local
  • Make a link from ~/Music/iTunes to ~/Music/iTunes.local
  • Make a link from ~/Picutres/iPhoto_Library to ~/Pictures/iPhoto_Library.local
  • Write a script to change the links to the appropriate library upon mount
  • Write a script to change the links to the appropriate library upon unmounting the external disk
  • Use Lingon to make my mounting script run when a disk is mounted.
  • Use Lingon to run my unmounting disk when the mount point changes.
Read on for the scripts I use...

My Mounting Script:
#!/bin/bash

HOME=/Users/username
GRAID_MOUNT="/Volumes/G-RAID_MINI"

IPHOTO_TAIL="iPhoto_Library"
IPHOTO_TAIL_LOCAL="iPhoto_Library.local"
IPHOTOLIBRARY_LINK=$HOME/Pictures/$IPHOTO_TAIL
IPHOTO_GRAID=$GRAID_MOUNT/Photos/$IPHOTO_TAIL
IPHOTO_LOCAL=$HOME/Pictures/$IPHOTO_TAIL_LOCAL

ITUNES_LINK=$HOME/Music/iTunes
ITUNES_GRAID=$GRAID_MOUNT/Music/iTunes
ITUNES_LOCAL=$HOME/Music/iTunes.local

if [ -d $GRAID_MOUNT ]; then
  echo ........ G-RAID MOUNTING ..........
  `rm  $IPHOTOLIBRARY_LINK `
  `ln -s $IPHOTO_GRAID $IPHOTOLIBRARY_LINK`
  `rm $ITUNES_LINK`
  `ln -s $ITUNES_GRAID $ITUNES_LINK`

echo DONE CHANGING IPHOTO AND ITUNES LINKS 
exit 0
fi

echo ERROR DISK NOT MOUNTED
My Unmounting Script
#!/bin/bash

HOME=/Users/username
GRAID_MOUNT="/Volumes/G-RAID_MINI"


IPHOTO_TAIL="iPhoto_Library"
IPHOTO_TAIL_LOCAL="iPhoto_Library.local"
IPHOTOLIBRARY_LINK=$HOME/Pictures/$IPHOTO_TAIL
IPHOTO_GRAID=$GRAID_MOUNT/Photos/$IPHOTO_TAIL
IPHOTO_LOCAL=$HOME/Pictures/$IPHOTO_TAIL_LOCAL

ITUNES_LINK=$HOME/Music/iTunes
ITUNES_GRAID=$GRAID_MOUNT/Music/iTunes
ITUNES_LOCAL=$HOME/Music/iTunes.local

if [ -d $GRAID_MOUNT ]; then
  echo  GRAID NOT UNMOUNTED  
  exit 0; 
fi

echo .....  GRAID IS BEING UNMOUNTED
`rm  $IPHOTOLIBRARY_LINK `
`ln -s $IPHOTO_LOCAL $IPHOTOLIBRARY_LINK`
`rm $ITUNES_LINK`
`ln -s $ITUNES_LOCAL $ITUNES_LINK`

echo    DONE UNMOUNTING GRAID
Lingon Changes I added two agents to Lingon:
  • com.username.Folderactions.GRAIDMount:
    • What: points to my mount script
    • When: Run it everytime a volume is mounted
  • com.username.Folderactions.GRAIDUnmount
    • What: points to my unmount script
    • When: Run if this file is modified: /Volumes/G-RAID_MINI
The only catch I've found is that there are major problems with this script if spaces exist in the file name -- the bash scripts seem to have a very hard time with the space issue. I couldn't find a solution in scripting, so I simply changed the names of the folders and had iTunes/iPhoto point to an underscore instead. Same goes for the external hard disk.

If anyone sees any errors in this, or has any thoughts on a better way to get this done, I'd be interested in reading what you have to say.
    •    
  • Currently 1.63 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (8 votes cast)
 
[10,616 views]  

Share a music/photo hard drive between two systems | 12 comments | Create New Account
Click here to return to the 'Share a music/photo hard drive between two systems' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
spaces in filenames
Authored by: airdrummer on Jun 23, '09 10:28:34AM

just doublequote any instance...

btw, $HOME is usually defined already, as is $USER so you could avoid hardcoding that...



[ Reply to This | # ]
just noticed the backticks...
Authored by: airdrummer on Jun 23, '09 10:32:38AM

why are you executing your commands in a subshell?



[ Reply to This | # ]
Share a music/photo hard drive between two systems
Authored by: rworkman on Jun 23, '09 11:14:48PM

Move ~/Music/iTunes to ~/Music/iTunes.local
Move ~/Pictures/iPhoto Library to ~/Pictures/iPhoto_Library.local
Make a link from ~/Music/iTunes to ~/Music/iTunes.local
Make a link from ~/Picutres/iPhoto_Library to ~/Pictures/iPhoto_Library.local

Would the steps above be the best way to share itunes and iphoto libraries between different accounts on the same mac using the shared folder?



[ Reply to This | # ]
Sharing between two users
Authored by: airdrummer on Jun 24, '09 05:40:45AM
i think you mean:
mv ~/Music/iTunes /Users/Shared/Music/iTunes.local
mv "~/Pictures/iPhoto Library" "/Users/Shared/Pictures/iPhoto Library.local"

and then for each user:
ln -s ~/Music/iTunes to ~/Music/iTunes.local
ln -s "/Users/Shared/Pictures/iPhoto Library.local" "~/Pictures/iPhoto Library"

i think that would work (after setting permissions or ACLs so all had rw access) but i think there'd be contention on simultaneous write access...

[ Reply to This | # ]
Sharing between two users
Authored by: atonaldenim on Jun 26, '09 12:31:50PM

I use essentially this same method to share my iTunes library between two local users on my Mac. The only problem I can think of after a year or so of doing this, is that after installing any iTunes updates, the permissions on the shared iTunes library are reset. I have to manually give the other user read-write permissions on the shared iTunes folder.



[ Reply to This | # ]
Share a music/photo hard drive between two systems
Authored by: maxz on Jun 24, '09 01:23:56AM

Just as airdrummer points out, don't use backticks for your commands in the bash scripts, it serves no purpose in this case.

Also, by enclosing the variable subsitutions in double quotes, for example:

[code]rm "$IPHOTOLIBRARY_LINK"[/code]

the script handles files and paths with spaces.



[ Reply to This | # ]
Share a music/photo hard drive between two systems
Authored by: garyhanna2 on Jun 24, '09 08:00:55AM

Would it not be easier after copying the iPhoto Library and the iTunes library to the External Drive to hold the Option key when launching the Apps from the laptop and choosing these Libraries.
No Scripts or Links files necessary.



[ Reply to This | # ]
Share a music/photo hard drive between two systems
Authored by: spartanoverseas on Jun 24, '09 07:38:07PM

If I only did this once in a while, maybe. But this hard drive follows me around and I'm constantly plugging and unplugging it. And it's safe to say iTunes is almost always up on my computer.

How many clicks were involved in writing the script? Probably more clicks than I've saved. But it's still helpful and saves me a little time.



[ Reply to This | # ]
Share a music/photo hard drive between two systems
Authored by: spartanoverseas on Jun 24, '09 09:22:00AM

Hrm.. I tried double quoting that and I swear it didn't work. I started using the subshell while trying to figure it out and maybe that's where I started bumping in more issues.

Thanks for the tips.



[ Reply to This | # ]
Share a music/photo hard drive between two systems
Authored by: jiclark on Jun 24, '09 12:33:25PM

Could you (or someone) explain why your technique is preferable to the technique mentioned above, where you simply tell iTunes to use a different Library at startup, and it continues to use that Library until you tell it to use a different one??

What benefits are there in using this rather complicated hint (at least for those of us with minimal CLI skills!)?



[ Reply to This | # ]
Share a music/photo hard drive between two systems
Authored by: maxz on Jun 24, '09 03:50:42PM

I think it is rather obvious, once you have set it up you don't have to do anything other than plug in the external drive. Not that pressing a button at the application start-up is hard, but still...

What is suggested is an automated approach, harder to set up, no work later. It just follows the idea that any manual labor that is repeated might be worth to automate. If you do it once or twice, it is probably faster/cheaper to do it by hand.

If one only could script the computer into plugging the external drive by itself :-)

Don't be afraid to learn to use the terminal. Even with minimal knowledge of CLI you will see that the potential for your Mac increases dramatically.



[ Reply to This | # ]
Share a music/photo hard drive between two systems
Authored by: pda on Jan 07, '11 01:49:23PM

Here is how I did it for iPhoto. Create a "sparse image" disk image of the size you might think you'll need. It can be increased latter if needed. Do this using the Disk Utility. I called mine simply Photos
Place the image in the Macintosh HD/Users/Shared directory. Since it will be locally mounted, I give everyone rights to it. Copy your iPhoto directory to it and change the location within iPhoto so it knows where to find it's files.
Automount the image at login. The mounted disk icon will show up on everyones desktop. You can actually run iPhoto by double clicking the disk icon.
The only down side is that a user locks the disk image for exclusive use. That mean that if Sally has iPhoto open and Bobby decides to login and run iPhoto he will get a warning that the disk is locked and he will not be able to access it until Sally closes the application. Users have to be considerate and close the app when they walk away from the machine.



[ Reply to This | # ]