From the author:
This simple app lets you sync your iPhone music/videos with more than one computer by keeping two iTunes libraries on the iPhone and allowing you to quickly swap between them whenever you like.
The reason I wrote this is because I have different videos and music on both my home PC and my work PC. Unfortunately, iTunes does not allow you to sync music/videos to more than one computer. So, until there is software like Floola, Poddox or Sharepod for the iPhone, I created this simple solution.
Here is the detailed way it works:
The first time you run it, it will move the iTunes library on your iPhone (where all your music, videos, podcasts and artwork is stored) somewhere safe and replace it with an empty one. If you run the iPod app on your iPhone at this point, you’ll see that there is no content in it. Don’t panic! Your library is still there and you could go back to it by simply running SwapTunes again.
But much more interestingly, at this point you can sync your iPhone to a different computer than the one you usually sync to. To play it safe, prior to connecting your iPhone to the second computer, make sure you disable automatic syncing on it (in iTunes go to iTunes (for Mac)/Edit (for PC) -> Preferences -> iPhone, and select “Disable automatic syncing for all iPhones”). Then you can connect your iPhone, but prior to acutally syncing, make sure you only sync podcasts, videos and music, nothing in the Info or Photos tabs. Info and Photos are not stored in the iTunes library on the iPhone and would be overwritten if you sync them on the second computer.
So now the music/videos/podcasts that you just synced with your iPhone will be available through the iPod app as you would expect.
From now on, every time you run the SwapTunes app, it will switch to your other library, effectively allowing you to have two complete iTunes libraries on your iPhone and effortlessly swap between them. It will even keep any bookmarks you had on a video or audiobook before the swap and resume playing from where you left off.
Just make sure to swap to the corresponding library before syncing to one of your computers. But don’t worry, if you forget to do this, iTunes is smart enough not to override any data without your permission, even if you enable auto-sync. I found that iTunes actually automatically unchecks the music/videos/podcasts checkboxes when it does not recognize the library on the iPhone.
If you have comments or suggestions, feel free to submit them here: http://modmyiphone.com/forums/showthread.php?t=3022.
In the future, I might improve it to allow for more than two libraries. I don’t have an urgent need for it right now but if enough people request it, I’ll see what I can do.
The code is extremely simple (a bash script) so don’t be afraid to tweak it to your liking. I actually encourage you to have a look at swapTunes.sh to see what it’s doing (kill the music player process, then move folders around).
Be sure to back up your music library before you try it, just in case something goes wrong. It works great on my iPhone but of course, this comes with no guarantees whatsoever and use it at your own risk.
Philippe
(With minor editing by Ste)