Productivity

How To Sync iTunes Across Multiple Computers Using Dropbox

If you run iTunes on multiple devices, chances are you’ve had trouble keeping your libraries in sync. Maybe you’ve even tried Dropbox but ran into syncing conflicts. Here’s how to sync iTunes with Dropbox problem-free, on Windows or Mac.

Why Would I Want to Do This?

Aside from the benefit of having all your iTunes media in sync and backed up, you gain a lot of additional conveniences by syncing your music library using Dropbox. Most of these conveniences will help you get more from your smartphone or mobile device. If you have any mobile device that has an official Dropbox app available (currently that means iOS, Android, and Blackberry), you can access all of your iTunes media directly from your device without the need to sync. If you have an iDevice device, you’ll no longer be restricted to syncing it with a single machine. With your iTunes libraries completely in sync, your iDevice will recognise them as the same library — regardless of which machine you’re using. This means that no matter which machine you use, your iDevice will gladly sync with it. The last major benefit comes in when you don’t have access to any of your devices. Since everything is synced to Dropbox, if you want to play a song for a friend, you can simply log into Dropbox on their machine and you’ll have quick access to everything you keep in iTunes.

What You Should Know Before You Get Started

This Will Probably Cost You Some Money

Unless your iTunes library is small enough, you’re probably going to have to start paying for Dropbox to do this. Dropbox is generous enough to provide you at least 2GB for free (and up to 16GB if you refer people — possibly more if you’re a good samaritan), so if you can fit your music library into your free space then this won’t cost you a thing. If you’re like me (and probably most people), however, you’re probably going to need to pay for a 50GB or 100GB Dropbox account, which will cost you $US10 or $US20 (respectively, with discounts for pre-paying for the year). We love Dropbox and feel it’s worth paying for (the extra space comes in handy for more than just music syncing), but ultimately that’s a choice you’re going to have to make for yourself.

Syncing with Dropbox Comes with Two Problems — Which We’ve Solved

Whatever your situation may be, it’s very easy to simply sync the music files in your iTunes folder to Dropbox. We’ll go over how to set everything up, but it’s fairly easy: you just move your iTunes folder into your Dropbox and tell iTunes where it is. While this part is very straightforward, it introduces a couple of problems.

First, everything in your iTunes library must be uploaded to Dropbox and then synced to your other machines. One benefit of selective sync in the latest Dropbox release is that you don’t have to sync your entire library to, say, your netbook’s tiny hard drive unless you want to. While syncing to your other machines can be quick if you have LAN sync enabled in your Dropbox preferences, uploading everything to your Dropbox can be fairly time consuming. If you have a very large library and a slow upstream connection, this method may not be for you. If you can gather enough patience to make it past the first big upload and your upstream connection is 768kbps or greater, you’ll be in good shape.

The second problem is that, because of how iTunes handles the iTunes library file, you can only have one copy of iTunes open at once. Pretty much every tutorial on the web that tackles this subject will simply tell you to remember to only keep one copy of iTunes at a time. We felt that if we were going to do a tutorial on the subject, this problem would need a better solution. Syncing and backing up your iTunes libraries is supposed to make your life easier. If you always have to remember to close iTunes before opening it up on another machine (to prevent any syncing issues), it’s not necessarily making your life easier. While there isn’t really a perfect solution to this problem, we’ve figured out a method that works well for us. First we’re going to take a look at syncing your iTunes library with Dropbox, and then we’ll cover your options for making this syncing experience as painless, easy, and effective as possible.

Syncing Your iTunes Library with Dropbox

Syncing is the easy part, although it will involve a lot of waiting as Dropbox uploads all your music, videos, and anything else you keep in your iTunes folder. Although you shouldn’t have any issues, we recommend making a backup of your iTunes library with an external hard drive so you can easily recover should something go awry. Better safe than sorry!

Step One: Move Your iTunes Library

Find your iTunes Library folder and move it to your Dropbox. So long as it’s in your Dropbox, you can put it wherever you want. The important thing is that it is in the exact same place on all your machines, otherwise iTunes can get confused So long as your Dropbox location doesn’t vary from machine to machine, you should be just fine.

Step Two: Wait

Even if you have a ridiculously fast connection to the internet, syncing gigabytes of files is going to take some time. You can always pause your Dropbox sync should you need your connection, but your best bet is letting this happen overnight and on the weekend so you can avoid any trouble associated with long uploads.

Step Three: Set the New Location of Your iTunes Libraries on All Your Machines

Congratulations! You’ve now survived what may go down in history as the longest upload of your life. With that out of the way, you need to tell every copy of iTunes — on every one of your machines — where to look for its library. The easiest way to ensure you don’t run into any issues is launch iTunes and immediately hold down the alt/option key. Doing this will prompt iTunes to ask you to choose your iTunes library. Do this and select the newly synced iTunes library inside of your Dropbox. Be careful to make sure you select the exact same location on all machines or you can expect trouble. This should be easy enough to do, but it never hurts to double check as your music library will get very disorganised if these locations are not exact.

Step Four: Test It Out

Because we have yet to solve the problem of keeping only one copy of iTunes running at the same time, when you perform your tests you need to make sure you manually close iTunes before opening it on another machine. That said, try copying some new songs to iTunes on one computer. When you’re done, quit iTunes and open it up on another machine. If those songs are already there — as they should be (if you have LAN sync enabled) — smile, because it worked!

Ensuring Only One Copy of iTunes is Open on All Your Machines

The big challenge posed by this syncing process is keeping iTunes open on only one machine at a time, no matter where you are. The process isn’t hard, but it does involve a little work. It also differs between operating systems, so here are instructions for both Windows and Mac OS X.

On a Windows PC…

Solving this problem is very easy on Windows. All you need is AutoHotkey and a text file. If you’d

Step One: Download and Install AutoHotkey

If you don’t have AutoHotkey already installed, you can download it here (you want AutoHotkey_L). Install it and open up the default script in notepad (or whatever text editor you prefer).

Step Two: Add and Edit the Following Commands to Your AutoHotkey Script

Copy and paste the following code into your AutoHotkey script:

<; Check the text file to see which computer most recently launched iTunes.
; If it is not the same as the computer running this script, iTunes will quit.
#Persistent
SetTimer, Alert1, 5000 ; Timer to check every 5 seconds
return

Alert1:
FileRead, FileReadVar, C:test.txt
if (FileReadVar != A_ComputerName)
{
   IfWinExist, ahk_class iTunes
   Process, Close, iTunes.exe
   return
}
return

; Launch iTunes and save a file with the network name of the computer running this script.
; This will let other computers running this script know that they should quit iTunes.
^#t::
Run iTunes.exe
FileDelete, C:test.txt
FileAppend, %A_ComputerName%, C:test.txt
return</blockquote>

Before you save and reload your script, you need to make a couple of changes. First, you’ll notice there’s a path to a file called test.txt. Currently it’s located on the root of your C: drive, but you want this file to be somewhere inside of your Dropbox folder. You can name the file anything you want and put it anywhere in your Dropbox, but just make sure whatever name and location you choose is specified consistently in the AutoHotkey script.

The second change is not necessary. Currently the script requires you to open iTunes using Control+Windows+T (written as ^#t in the script). You’re welcome to change this command to anything you’d like. Whatever you use, you need to use this command to open iTunes from now on because in addition to opening iTunes, AutoHotkey will also create the text file. In the text file it included a copy of your computer’s network name. That text file will sync in your Dropbox to all your machines. Every five seconds, the AutoHotkey script will read that file to check the network name of the most recent computer to launch iTunes. If the machine running the script finds that the name in the text file is the same as its own network name, it’ll allow iTunes to continue running. If it doesn’t match, it will quit iTunes because it will now know that another machine has more recently launched iTunes. This will prevent iTunes from running on two machines at the same time.

On a Mac…

If you’re on a Mac, this is really simple with a free utility called Do Something When and a little bit of AppleScript.

Step One: Enable Remote Apple Events

First things first, you need to enable Remote Apple Events on all of your machines. You can do this by going into System Preferences —> Sharing and checking the box next to Remote Apple Events. By default this will enable the option for all users, but you can opt to enable it for only your user.

You need to do this for all of your machines because every machine will be receiving a remote event every time iTunes opens on any of them. Because this needs to work not only locally but remotely as well, you can’t just use local IP addresses. This isn’t a big deal if you only have a desktop and a laptop as you can just set your router to forward port 3031 — the port used for Remote Apple Events — to your desktop. If you have multiple machines you’ll have to get a little creative with your network setup by either remapping ports or using a VPN to avoid the problem altogether. Alternatively, if you don’t want to go through that trouble, you can instead write an extra AppleScript on one desktop machine and use an Apple Remote Event to run that instead. That extra AppleScript can use the methods described in the next section to quit any running copies of iTunes.

Step Two: Use AppleScript to Quit Copies of iTunes

To quit iTunes remote, you don’t need more than a few lines of AppleScript. Open up AppleScript and enter the following, replacing YOUR-IP with the IP address of the machine you want to target:

<b>tell</b> <em>application</em> "iTunes" of <em>machine</em> "eppc://YOUR-IP"
<b>quit</b>
<b>end tell</b>

Run the script to test it. You may have to enter and save your username and password the first time, but after you do that the script should succeed in quitting iTunes remotely. If you have more than one machine, you’ll need to simply repeat the statement for as many machines as you’ve got. Just make sure the IP addresses are correct for each machine. If you’re quitting iTunes on a local machine, you can simply use the Bonjour name (e.g. Joannas-iMac.local).

Once your script is quitting an open copies of iTunes on other computers, save it as an AppleScript application. Note: you’ll need to repeat this process for every machine, creating a unique AppleScript and save it as an AppleScript application. This is because each computer needs to tell all the other computers to quit iTunes but leave its own running. If you copy that script to one of the other computers, it will leave iTunes running on the computer the script came from rather than leaving its own copy running. While the concept is pretty simple, it can be difficult to articulate, so if you’re confused don’t worry. If you don’t understand why this is necessary but follow the instructions anyway, you should be just fine.

Step Three: Download and Configure Do Something When

First things first, download Do Something When and install it. Once it’s installed, open up System Preferences and click DSW (which stands for Do Something When). If you’re running Mac OS X 10.6 (or higher) in 64-bit mode, System Preferences will need to restart in 32-bit mode to load DSW. Let it do this and then System Preferences should display the Do Something When interface. If you look down at the bottom part of the window, you’ll see some options.

The first option is Rule Name and that’s the first thing you need to fill out. You can set it to whatever you want, but I’ve named mine “Quit Inactive iTunes.” In the “When” drop down, select the Choose an Application… option and select iTunes. Right beside this selection will be a few options. You can choose to do something when iTunes launches or quits. You want to choose Launches.

The next line is the What line. From the first drop-down, choose Open. From the second drop-down, choose Select an Application or Document. This will provide you with a file browsing window and you’ll want to navigate to the AppleScript application you created in the previous step. Select the one for the computer you’re currently configuring and choose Open. Lastly, click the Save button to save your rule.

At this point you’re all done with this machine, although if Do Something When isn’t already running you’ll want to tell it to run by pressing the button at the top of the window. Now you’ll need to repeat this process for each computer syncing your iTunes music and you’ll be done!

And that’s that! This is by far the best method we’ve come up with, and the perks — like syncing your iDevice with any of your computers like they’re the same machine — are pretty nice. We’re open to improvements and suggestions, though, so if you’ve got any, let’s hear it in the comments.