iTunes Playlist To XML AppleScript

iTunes Playlist To XML AppleScript

Looking to share your music with others? Just set up a Smart Playlist in iTunes to show you recently played music and this script will publish that list to your web site.

Here is a quickly made demo of what you can do with this.



Q: How do I get this running?

The first step is to update the script with path information to the XML file to save out and the iTunes playlist. Then, create a command line script to call the AppleScript and pass in an FTP URL.

In the Terminal, start with creating a script file:

$ pico

Copy/past in the following two lines (editing the second for your FTP site):

osascript /path/to/iTunesPlaylistToXML.scpt ""

Save out the file and then set permissions to execute:

$ chmod 755

Test by running:

$ ./

The script should run and call the AppleScript. You should see a couple lines of text that end with "...file uploaded!".

Now that you have the script running from the command line, you can set it to run on a schedule. I've found the easiest way to do this is to use a tool called CronniX. This tool is a free front end to some UNIX tools already on your Mac. Set the file to run daily, hourly or more to upload to your site.

Q: What do I do with the track info?

My demo page processes the XML data with jQuery and writes out the track data. Here's the jQuery code:

$(document).ready(function() {
  $.get("../iTunesRecentPlaylist.xml", null,
    function(data) {
      $(data).find('track').each( function() {
         var name = $(this).attr('name');
         var artist = $(this).attr('artist');
         var album = $(this).attr('album');
           append("<li><b>" + name + "<\/b> by <b>" + artist + "<\/b> from <b>" + album + "<\/b><\/li>");


Let me know if you end up doing something else more creative.


Let me know if you have any problems with using the iTunes Playlist To XML AppleScript or if you have suggestions for future versions.