Forked from BigW72/jaikoz-rename-folder-compilation.js
Last active
August 29, 2015 14:12
-
-
Save cjlittle/17bd7c8f9de062039b43 to your computer and use it in GitHub Desktop.
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
/* -*-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