Scripting iTunes.. A look at Apple’s iTunes SDK
I came across the iTunes SDK while trying to find a way to automate the deletion of ghost song entries out of my iTunes library. Over time the iTunes library on my machine had become unusable, I had moved or deleted a bunch of of my music files with (not in iTunes) and thier entries remained in the iTunes library. I had always used iTunes for playing back music and had dealt with the inconvience of the ghost entries. With the arival of a iPod Nano at my doorstep, I found these entries to be truly annoying and determined that they needed to go. Sure, I could have just deleted the XML database files and gone through the process re-adding the folders to the library but that would have eliminated my play lists, play counts, last played, and ratings. So here enters the iTunes Software Development Kit (SDK) from Apple. This SDK shows you how to start using the Component Object Model (or COM) interface developed in the iTunes application. This COM interface allows you to use external tools to manipuate the actions of iTunes. Some people choose to use full blown developement environments like Visual Studio but since the Windows scripting host is installed by default on Windows XP machines we can use the notepad application. By using javascript and VBScript we create a text file that are interpreted by the Windows scripting Host (WSH) and executed with no need to compile or go through a setup program. I am not going dive into the intricacies of what a SDK is and how to use them in this article, for that I suggest you look to Google. You can download Apple’s iTunes SDK for Windows from Apples Developer’s site here. It is a small zip file, only 267KB in size. Please review the licensing agreement before you agree and download the SDK. I need to mention that while my experiences have been positive and I can’t be held responsible for negative end user experiences. The ZIP files contains the following files:
- iTunesCOM.chm - Compressed HTML help file containing the documentation on the iTunes COM interface.
-
iTunesCOMInterface.h - COM header file used when developing in C++.
-
iTunesCOMInterface_i.c - Also a COM header file used when developing in C++.
-
samples/RemoveDeadTracks.js - Iterates over your library and removes any tracks that can no longer be found on disk.
-
samples/RemoveUserPlaylists.js - Deletes all non-smart user playlists your library.
- samples/CreateAlbumPlaylists.js - Iterates over all tracks in your library, creates a new playlist for each album, and adds the tracks for that album to the playlist.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.
Comments
[...] I previously introduced you to the iTunes for Windows SDK in a previous article. As I mentioned in the previous article, I had just received my iPod Nano and came to the realization that my iTunes library was out of control. I discovered the iTunes SDK and the sample scripts it included. I was especially pleased with the RemoveDeadTracks script that deleted all the orphaned song entries that were left after I deleted the songs outside of the iTunes interface. I still had a problem with duplicate tracks, and decided it was the perfect oportunity to use the SDK to automate the deletion of these duplicate tracks. After spending a little time getting acquainted with the SDK I broke out my favorite script editor (windows notepad) and started to get to work. [...]
This article has been Dugg! http://digg.com/apple/Scriptin.....iTunes_SDK
[...] <!–adsense#button–>I looked at the iTunes SDK in “Scripting iTunes.. A look at Apple’s iTunes SDK” and I have shared with you a script I have wrote to eliminate duplicate song entries in your iTunes library in “Using the iTunes SDK to Remove Duplicate Songs“. I have used the feedback to help improve this script and am working on a way to remove the orphaned (or dead) song entries using VBScript. [...]
[...] This is a continuing look at what we can accomplish with the iTunes SDK. If you have missed the previous articles in this series please take a look at An introduction to Apple’s iTunes SDK, Removing Duplicate Songs, and Removing Orphaned Songs. [...]

Ipod1 cheap
I am Karin, very interesting article that contained the information I was searching for in Google, thanks.