Scripting iTunes on Windows
At the Apple developer site I found a COM SDK for iTunes.
This allows anyone with a little JavaScript knowledge to script the iTunes app from the command line.
Its a reasonably easy object model to understand and makes batch processing of the iTunes library very easy.
Here's a simple script to list albums in your library (ListAlbums.js).
To run it, use the thevar iTunesApp = WScript.CreateObject("iTunes.Application");
var mainLibrary = iTunesApp.LibraryPlaylist;
var tracks = mainLibrary.Tracks;
var numTracks = tracks.Count;
// array of albums, keyed by name, value of array element is the artist
var albumArray = new Array();
for (i = 1; i <= numTracks; i++)
{
var currTrack = tracks.Item(i);
var album = currTrack.Album;
WScript.Echo("Processing track, Name: '" + currTrack.Name + "', by Artist: '" + currTrack.Artist);
if ((album != undefined) && (album != ""))
{
if (albumArray[album] == undefined)
{
WScript.Echo("Adding album " + album);
albumArray[album] = currTrack.Artist;
}
}
}
// dump out albums
var count = 0;
for (var name in albumArray)
{
count++;
WScript.Echo("Album[" + count + "] = " + name + ", by " + albumArray[name]);
}
This allows anyone with a little JavaScript knowledge to script the iTunes app from the command line.
Its a reasonably easy object model to understand and makes batch processing of the iTunes library very easy.
Here's a simple script to list albums in your library (ListAlbums.js).
To run it, use the the
cscript command.