Saturday, April 5, 2008

Camel Caps Title and Artist in iTunes

I DON'T LIKE ALL CAPS LIKE THIS. I prefer my music titles to: "Use Camel Caps". And I'm tired to renaming each of the 1000 Top Songs Of The 80's. Here is my solution:

1) Save the snippet below into: MarkyCamelCapsSelectedSongs.js




// m_a_r_k_y@yahoo.com 2008-04-05 Initial

var iTunesApp = WScript.CreateObject("iTunes.Application");
var selectedTracks = iTunesApp.SelectedTracks;
var numTracks = selectedTracks.Count;
var ITTrackKindFile = 1;

while (numTracks > 0) {
var currTrack = selectedTracks .Item(numTracks);
// is this a file track?
if (currTrack.Kind == ITTrackKindFile) {
title = currTrack.Name;
artist = currTrack.Artist;

//WScript.Echo(convertToCamelCaps(title) + " : " + convertToCamelCaps(artist));

currTrack.Name = convertToCamelCaps(currTrack.Name);
currTrack.Artist = convertToCamelCaps(currTrack.Artist);

}
numTracks--;
}

// camelcaps string converter
function convertToCamelCaps(str) {
var tempArray = str.split(' ');

for (var i = 0; i < tempArray.length; i++) {
tempArray[i] = tempArray[i].charAt(0).toUpperCase() + tempArray[i].substring(1).toLowerCase();
}

return tempArray.join(' ');
}




2) Open iTunes and select the songs you want to convert.
3) Double click MarkyCamelCapsSelectedSongs.js from explorer to run it.

You should see your selected songs get converted.

More Info here:
http://developer.apple.com/sdk/
http://www.nsc.ru/docs/ms/js/jstoc.htm
http://www.asp.dk/docs/jscript/jstutor.htm

Enjoy!

No comments: