I had a bunch of tracks named by disc number, track number, and name, in the format "<disc> - <track>. <name>"
, so I wrote a quick Windows JScript tool to automate their renaming (and setting their ID3 values) through regex for me.
Usage
Open iTunes, select all tracks that match your criteria, then run the script (in a *.js
file).
Code
var ITTrackKindFile = 1;
var objApp = WScript.CreateObject("iTunes.Application");
var tracks = objApp.SelectedTracks;
var numTracks = tracks.Count;
var i = 0;
var reg = /([0-9]+) - ([0-9]+). (.*)/i;
while (numTracks != 0) {
var currTrack = tracks.Item(numTracks);
if (currTrack.Kind == ITTrackKindFile) {
var nDisc = currTrack.name.match(reg)[1];
var nTrac = currTrack.name.match(reg)[2];
var nName = currTrack.name.match(reg)[3];
currTrack.name = nName;
currTrack.trackNumber = nTrac;
currTrack.discNumber = nDisc;
}
numTracks--;
i++;
}
WScript.Echo("Data adjusted for " + i + " tracks.");