Synchronize Two iTunes Libraries

iTunes Home Sharing feature is a great way to listen to content in other iTunes libraries around your house. It’s also pretty simple to copy individual songs. In my case though neither of these options are quite good enough.

I am a multiple Mac household. I have a MacBook Pro for work, my wife has a MacBook and my kids and I share an iMac as the family computer. I was keeping my iTunes library on my iMac but since I’ve begun using my MacBook Pro I’ve wanted to have my music there.

What I really want to do is have an easy way to keep both the iTunes library on my iMac and MacBook Pro synchronized. After doing some searching around I found that it’s pretty easy to do with some features built right into Mac OS X.

At the end of this article you should be able to sync your iTunes library from one Mac to another.

Update : This problem has been addressed with iTunes Match. iTunes Match is a pretty low cost way to keep your iTunes libraries in sync across all of your iDevices.

Note that I only intend to do a one way sync. This means I’ve picked one of my two libraries to act as the master library that will sync to the second library. It’s possible to sync both ways but I feel it is safer to just go one way.


Getting Started

The first step is to ensure that each Mac can see each other. Open up the Finder window on each Mac and look in the sidebar (the left side of the Finder window). You should be able to see the other machine. If you see it you have file sharing enabled. If you can’t, you need to enable file sharing following the steps below.

Enable File Sharing

Open System Preferences and select Sharing. Then ensure that the check box for File Sharing is checked. This will allow you to access each file using the Apple Filing Protocol (AFP)
Enable Mac OS X File Sharing

Sync iTunes using Automator

Ok, so now that you have your two machines seeing each other the next step is to actually transfer your library from one machine to another.

Before we get to that, let’s think about the tasks we need to accomplish. For this application we need to do the following:

  1. Connect Mac A to Mac B
  2. Copy the iTunes Library from Mac A to Mac B
  3. Disconnect Mac M from Mac A

In order to do this we’re going to turn to some UNIX shell scripting and Automator. Don’t worry if you don’t know what UNIX shell scripting is. It’s super easy and will help you realize the power underneath the hood of your Mac.

Launch Automator

Open Automator and select that you want to create a new Workflow. We can save this as an application later.

Next, we need to setup our Automator Workflow. Let’s think back to the steps we identified. The first step is Connect Mac A to Mac B. We can do this with the Get Specified Servers Action. Find it from the list of actions and drag it over to the Workflow window.

Now that it’s here, you need to add the target Mac’s file share information. Select Add and then select the computer from the list. Then append the name of the user on the target machine that has the iTunes library. In my case it’s Dad so I add /Dad to the name of the server and click Ok.

The next step is to actually connect to that server. Grab the Connect to Servers action and drag it below the last action. Once the connection is made, we run the command that actually copies the files. For  that we turn to a powerful UNIX command rsync.

Drag the Run Shell Script into your workspace and attach it below the last action. Now, you can enter the command that performs the copy. Copy and paste the following.

rsync -av --force --delete --dry-run 
~/Music/iTunes /Volumes/Dad/Music > ~/Documents/iTunesSync.log

The rsync utility is essentially a backup tool used to keep directories synchronized. Unlike a simple file copy rsync looks at things like the size and date of a file to decide whether or not it should do the copy. The first time you do your sync it will take a while. After that, every time you run rsync it will only copy over the files that change.

So you know what’s going on, let’s walk through each of these options. The -av option tells rsync two things 1) this is archive mode which tells rsync to behave in a way that works well for backups and 2) be verbose and tell us what you are doing. The –delete switch will remove files from Mac B that are no longer on Mac A. This way if you remove files in your iTunes library rsync will reflect those deletions in the other iTunes library.

The switch –dry-run is your safety net while we’re building this script. With the –dry-run option we won’t actually copy the files. When we are all done, we’ll remove the switch.

The next two parameters are the source path and the destination path. The source path is where your main iTunes library is. Typically it’s in your home directory (~) in Music/iTunes. Change this as needed. The destination path is the location where we are sending this iTunes library to. For me it is /Volumes/Dad/Music. For you it is whatever directory you connected to when you ran the Get Specified Servers Automator action.

Finally we are going to send the output of rsync to a file so we can review it later to make sure everything worked ok.

This was the most complicated part of the Workflow. The next and final step is to disconnect the two computers. Drag the Eject Disk action and attach it below the Run Shell Script action.

At the end of the process you Workflow should look like this.

Testing the Workflow

Now that you’ve built the workflow, let’s test it. You’re going to run the workflow and look at the log file to see if things look ok. If everything is ok we can remove the –dry-run switch

Note that what we’re doing could be dangerous! If you setup the rsync command incorrectly you could end up deleting your iTunes library. This is why we use –dry-run first. Make sure you have a backup of your library handy in case something goes wrong.We’re not responsible if you hose your music library.

Ok, with that bit out of the way, let’s run the test. Click the play button to run the automator workflow.

The first thing that may happen is you are prompted for a password. This is part of the network connection process. Choose the user name you use to login to the account with the iTunes library.

As Automator works through each step of the process, you’ll see it place a green check next to each action. The longest part of the process is going to be rsync. Remember though at this stage we are not actually copying files so this still should only take a few minutes to complete.

When everything is finished we’re going to look at the results. Open up your Documents folder and look for the files iTunesSync.log. Open that up in a text editor and look at what is going on. You should see a list of files that rsync is trying to copy. If this seems ok to you then you’re ready for a live test.

Remove –dry-run from the shell script. Now, save the Automator Workflow. Choose File->Save As. Then, place it somewhere you will remember it. I put mine in ~/Applications and change the File Format from Application. This will let you run it directly without first going into Automator.

Once it is saved, click the Play button again and go make a sandwich you’ll be waiting for a while.

If you want to tune in to what is happening you can do a little more UNIX-fu. Run the Terminal command. In the Terminal Window, go to the ~/Documents folder (or where ever you put your iTunesSync.log file) and type the following:

tail -f iTunesSync.log

This will let you watch what is happening as the Automator script runs.


That’s it. You’re now able to keep your iTunes libraries in sync. What I find really cool about this is it touches on a lot of more advanced things you can do in OS X. Automator let’s you fairly easily create your own programs to solve problems and UNIX shell commands which let you do some pretty powerful things.


  1. Will on January 27, 2011 at 9:30 pm

    Thanks for this. The script is running right now. I searched for hours looking for a solution because I wanted to sync my MBP iTunes to my new Mini that I’m using as a home entertainment server but obviously home sharing won’t work when I have my MBP on the road.

    Will the playlists convert too? I guess I’ll figure that out in a few hours when this finishes.

    • Joe on February 10, 2011 at 7:19 am

      Yes, the playlists should copy too. You’re basically mirroring the two folders. If the article helped you please Like us on Facebook or Tweet about us. Thanks.

      • Tony on June 11, 2011 at 7:33 pm

        I must be missing something here. How does this synch the playlists? If I manually copy new music files into my iTunes music library folder in the Finder, then open iTunes, the music doesn’t appear in the iTunes “music” folder.

  2. Kyle Hayes on February 21, 2011 at 11:26 am

    Great tip! I just ran through it myself and it seems to be working. I submitted it as a tip to Lifehacker as well.

    How would I add a third computer to the equation?

    • Joe on March 3, 2011 at 11:34 am

      @Kyle – that’s a good question. I was thinking about this the other day too. I may end up extending the script to copy two multiple destinations.

  3. Kaspars Dancis on June 2, 2011 at 6:34 am

    You may also try AutoTunes – it synchronizes iTunes library with a folder. It won’t synchronize your playlists and ratings, however it’s much easier to setup and it can be used in several different ways such as in combination with Dropbox.

  4. Ryan on May 14, 2012 at 2:53 am

    I have an iMac that holds an expansive catalog, and I want to copy only a playlist or two onto my macbook air, is this possible using automator?

    • Joe on May 14, 2012 at 7:33 am

      Might be easier just to use Home Sharing if it is only one or two playlists.

  5. Tomi Fischer on August 23, 2012 at 4:12 am

    Hi, I tried to sync my two libraries but it didn’t work right for me for some reason. I ran the script from the computer that had all my music (computer A), so when it synced up with the one that had none (computer B) I got all the tracks in my library but when I tried to play them the files couldn’t be found.

    When I ran the automator script there was an issue with the ejecting (it said it was successful but there was a warning). There could also be the issue that my library on computer A is located in my shared folder. Do I need to change something in the script to fix this?

  6. mihnea on January 18, 2013 at 2:47 pm

    Thanks for the script!

    It works only partially for me since it creates a folder named Music inside the Music folder on the target Mac. Don’t know why. Here’s my script:

    rsync -av –force –delete –size-only ~/Music /Volumes/mihneam/Music > ~/Documents/iTunesSync.log

    On the source Mac the music library is in the Music folder, not Music/iTunes.
    Thanks for your help!

    • Joe on February 9, 2013 at 8:35 am

      Take Music out of your destination, do a dry-run and see if that helps. It looks like the command is saying to copy the Music Folder to another folder named Music. I think that is why you are seeing a folder within a folder.

      Again, make sure you do a dry-run first to see if this is correct.

  7. Chris on February 4, 2013 at 6:52 pm

    Hi, all seemed to be fine before i deleted the dry run command. The automator says that it cant find the directory that i have specified.

    I checked spelling to make sure and its perfect.

    • Joe on February 9, 2013 at 8:29 am

      It’s tough to say what the problem is without more information. Does the dry run work ok?

  8. Julius B on April 15, 2013 at 9:04 pm

    Joe, what methods do you know of for a two-way sync? The only thing I’ve been able to come up with is putting my itunes library file into dropbox, and hosting the library on computer b from the dropbox.

  9. Daniel Birch on April 28, 2013 at 4:17 pm

    I get this error:
    rsync version 2.6.9 protocol version 29
    what am I doing wrong?

    • Joe on April 28, 2013 at 4:57 pm

      The version of RSYNC that ships with OS X is really old. I’m not sure where you are syncing but my guess is you have a mismatch between the two rsync protocols.

      You can use Homebrew to update rsync to the latest version. That might help you.

      • Daniel Birch on April 28, 2013 at 5:35 pm

        Thank you very much.
        I eventually got rid of that error message only to encounter several more. At the moment I’m getting rsync: delete_file: unlink “………………”
        even though I I have granted all the necessary permissions. I can read and write on the files that it says I cannot touch. I feel like I’m really close but yet extremely far. Is there any way to help it?

  10. Vlad on October 17, 2013 at 6:20 pm

    Guys it would be so great with your scripting skills if oneday you come up with solution about syncing several mac’s with ONE itunes library located on NAS. I made a bit of research and found that there is NO app for that! What a pity! I mean it should be a very common task as many people now have several laptops – one for work, one for home, wifes, chidren and so on….

    So I think this script can be scheduled for may be copying few xml files from NAS to and then restart itunes?

Leave a Comment