Last active
December 25, 2015 21:12
-
-
Save dnicolson/03f75eed30770a2ac46c to your computer and use it in GitHub Desktop.
JavaScript OSA to remove track numbers in song names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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