Skip to content

Instantly share code, notes, and snippets.

@dnicolson
Last active December 25, 2015 21:12
Show Gist options
  • Save dnicolson/03f75eed30770a2ac46c to your computer and use it in GitHub Desktop.
Save dnicolson/03f75eed30770a2ac46c to your computer and use it in GitHub Desktop.
JavaScript OSA to remove track numbers in song names
var PREFIX_LENGTH = 3;
var itunes = Application('iTunes'),
selection = itunes.selection();
for (var i=0; i<selection.length; i++) {
var song = selection[i],
trackNumber = parseInt(song.name().slice(0, PREFIX_LENGTH), 10),
name = song.name().slice(PREFIX_LENGTH);
if (!isNaN(trackNumber)) {
song.trackNumber.set(trackNumber);
song.name.set(name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment