Applescript to Send Songs to a Shared iTunes Library

May 31, 2007 By: erik Category: Geeky 15,861 views

Rate this post:
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5.00 out of 5)

Note: To all of you that have found this post while searching for a way to copy songs FROM a Shared iTunes Library, read this. If you want to copy TO another iTunes library, then continue.

In my search for a solution to this problem, I have found that many other people find themselves in similar situations. Here’s a basic statement of the problem:

  • I have a laptop that I use at home but often take with me
  • I have a desktop at home with much more storage space than my laptop
  • I want to maintain all of my music on my desktop, but keep a subset on my laptop for playing when I’m not on my home wi-fi network.

Add to that my additional needs that…

  • I don’t even have a monitor, mouse or keyboard connected to my desktop machine
  • And therefore, I want to control adding music to my library completely from my laptop

The best solution that I was able to find from searching the internet is this dude that has his laptop using an iTunes library on a shared network drive on his server. Then, when he leaves the home network, he has a script to switch to a local library. The worst thing about that setup is that it could be complicated to add songs from your network server to your local library before disconnecting.

My solution is to add new songs to my local library, and then when I tire of them or need to free up some disk space, I send them to my shared library on the server. This way, I always have my newest music on my laptop, but if I want to listen to some older songs while I’m at home, I can connect to the shared network library inside iTunes. The trick to my solution is how I send the songs to the shared library, hence the title of this post.

I have written an applescript that will…

  1. Take the tracks I have selected in iTunes
  2. If any album art has been downloaded from the iTunes Store, and is therefore not embedded in the song file, embed album art into the song file
  3. Copy the files to a staging directory on the network server
  4. ssh to the network server and run an Automator script that…
    1. Takes all the files in the staging directory
    2. Adds them to the iTunes Library, which copies the files
    3. Deletes the files from the staging directory

The Script

This is the script that I have on my laptop. If you download it, the part at the top is all that you should have to change.

You may download the script here: Copy Songs To Archive Server.scpt

If you put the script in your “~/Library/iTunes/Scripts” directory, it will be available from the menu bar when you are in iTunes.

Note that, for the ssh to work without prompting you for a password, you must set up ssh key pairs. There are plenty of pages around telling you how. This is not one of them.

The Automator Workflow

This the Automator workflow that runs on the server. You have to export it from Automator to be an application.

Automator Workflow

You can download mine ( if you want, or you can just create your own from the above screenshot.

Fitting it all together

Obviously, you’ll have to edit the applescript to point to the correct staging directory, server, and location of the Then you just select the songs you want to copy in iTunes on your laptop, choose “Copy Songs To Archive Server” from the script menu, and watch them appear in the shared library. You can then delete them from your laptop if you want, and still listen to them over the network. I wouldn’t do more than 50 or 100 at a time, though. I’ve had “This script has stopped responding” timeout errors when I try more.

Questions and Comments

If you’re too lazy or paranoid to sign up and leave a comment here, you can email me at erikwordpressplugins -at- gmail. Happy song archiving!

  • This is very cool. I think I am too lazy to actually implement this, but I can certainly relate to your problem/situation, as it closely matches mine.

    One of the top three greatest things about the internet is, as you say, I have found that many other people find themselves in similar situations — that is, whatever niggling problem or vexation you’re undergoing, someone, somewhere, has already experienced it AND solved it — and taken the time to write up the solution somewhere for the good of all. I’m proud to know you, you solver, you.

    I mean, to the extent that I do know you.

  • Thanks for your solution.
    I’m lazy too, to write a script like this.
    But now it’s possible to run a Xserve with 500Gb of music and archiving it from 6 diverend places in the studio.
    Thanks for that.


    p.s. have a great wedding

  • Anon

    Thank you so much, this is the solution I have been looking for, and it is pretty easy!

  • Anon

    I decided to do it a bit differently:
    My mac mini will have itunes always on, with the library shared. When I import new songs on my macbook pro, the folder has is watched, and will automatically move the files to a staging folder. The staging folder is also watched, and is tied to an automator script that automatically starts running when new files are added. My automator script is almost the same as yours

  • The iTunes-Problem

    (Sorry for my bad english) 🙂


    Is it possible to copy all Songs from a “intelligent – iTunes – List” in to an other (normal, not intelligent Playliste).

    I have a big Libary on my Mac mini and would only copy automatically my “5 -Star – Songs” to my MacBook Air.

    I have a Mac Software called Syncopation. With this Software it is posssible to Sync 2 iTuneslibarys (Mac Mini and Macbook Air).

    It all works perfect, but the Software can only work with “normally not intelligent iTunes Playlist”.

    My Idea is that i have an Applescript for Copy all my 5 Stars-Songs from my intelligent List in to a normal Liste in the same iTunesLibary.

    And then Sync this normal Playlist over Airport-Network to my MacBook Air.

    Can you help me?

    thanks a lot!

    Regards from Switzerland!