Skip to content

Instantly share code, notes, and snippets.

@BigW72
Created December 18, 2013 10:17
Show Gist options
  • Save BigW72/8020090 to your computer and use it in GitHub Desktop.
Save BigW72/8020090 to your computer and use it in GitHub Desktop.
Jaikoz: rename file from metadata (compilation rename mask)
/* -*-javascript-*-
* Rename file from Metadata (Compilation rename mask)
*/
function pad(number, length) {
if (number == '') { return ''; }
var str = '' + number;
while (str.length < length) {
str = '0' + str;
}
return str;
}
function ifnotempty(value, sep) {
return value.length > 0 ? value + sep : '';
}
function ifnotempty2(value1, value2, sep) {
return value1.length > 0 ? value1 + sep : value2.length > 0 ? value2 + sep : '';
}
ifnotempty(pad(trackno, 2), ' - ') + ifnotempty(artist, ' - ') + title;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment