RegExp to capitalize all words in filename, without modifying existing camelCase or HumpCase words

Opus' regex dialect doesn't support capitalization. But a rename script is not too difficult.

// https://resource.dopus.com/t/regexp-to-capitalize-all-words-in-filename-without-modifying-existing-camelcase-or-humpcase-words/46680

function OnGetNewName(getNewNameData) {
    var allWords = getNewNameData.newname.split(' ');
    for (var i = 0; i < allWords.length; i++) {
        if (allWords[i].substring(1).match(/.*[A-Z].*/)) continue;
        allWords[i] = allWords[i].substring(0, 1).toUpperCase() + allWords[i].substring(1);
    }
    return allWords.join(' ');
}

Save 46680.orp to   

%appdata%\GPSoftware\Directory Opus\Rename Presets

How to use buttons and scripts from this forum

4 Likes