Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cjlittle/17bd7c8f9de062039b43 to your computer and use it in GitHub Desktop.
Save cjlittle/17bd7c8f9de062039b43 to your computer and use it in GitHub Desktop.
/* -*-javascript -*-
* Rename folder from Metadata (Compilation rename mask)
*/
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 : '';
}
year.length > 0 ? // The Year is provided
albumartist.length > 0 ? // The Album Artist is provided
albumartist + folderseparator +
albumartist + ' - ' + year + ' - ' + album + folderseparator +
(disctotal > 1 ? ifnotempty(album, '') + '(Disc ' + discno + ')' + folderseparator : '')
: // The Album Artist is not provided
album + ' - ' + year + folderseparator +
(disctotal > 1 ? album + ' (Disc ' + discno + ')' + folderseparator : '')
: // The Year is not provided
albumartist.length > 0 ? // The Album Artist is provided
ifnotempty(albumartist, folderseparator) +
ifnotempty(albumartist, ' - ') + ifnotempty(album, folderseparator) +
(disctotal > 1 ? album + ' (Disc ' + discno + ')' + folderseparator : '')
: // The Album Artist is not provided
ifnotempty(album, folderseparator) +
(disctotal > 1 ? album + ' (Disc ' + discno + ')' + folderseparator : '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment