Rename: First letter in uppercase and rest in lowercase

With Rename CASE=firstword we can convert names to sentence style, that is, the first letter is capitalized and the rest are lowercase, but when names begin with numbers this effect is not fulfilled, all letters remain lowercase.

Example:

001. TEST.jpg

001. test.jpg

How could I correct this situation with regular expressions?

Example:

001. TESTE.jpg

001. Teste.jpg

I have written:
Rename IGNOREEXT REGEXP PATTERN ([a-zA-Z]{1})(.*) TO \1 \2

but I don't know how to incorporate
CASE=upper
CASE=lower

or maybe it's not even possible.

Case changes are not supported. You'd need a script. There are few available on the forum.

Thank you very much @lxp for the information. There are really few scripts on the forum on the subject, I was analyzing one of yours, but I couldn't adapt it.

https://resource.dopus.com/t/renaming-capitalizing-first-letters-without-changing-following-letters/39883

Like so?

// https://resource.dopus.com/t/rename-first-letter-in-uppercase-and-rest-in-lowercase/46905

function OnGetNewName(getNewNameData) {
    var allWords = getNewNameData.newname.split(' ');
    for (var i = 0; i < allWords.length; i++) {
        allWords[i] = allWords[i].substring(0, 1).toUpperCase() + allWords[i].substring(1).toLowerCase();
    }
    return allWords.join(' ');
}

46905.orp

Pretty much like

:wink:

1 Like

Thank you very much @lxp for the effort, for the time, the result is almost perfect, but the way the script is, the first letter of all the words are converted to capital letters (Title style), but for me it was better at " sentence style" (only the first letter of the first word capitalized).

Here you go.

// https://resource.dopus.com/t/rename-first-letter-in-uppercase-and-rest-in-lowercase/46905

function OnGetNewName(getNewNameData) {
    var allWords = getNewNameData.newname.split(' ');
    var firstWordFound = false;

    for (var i = 0; i < allWords.length; i++) {
        allWords[i] = allWords[i].toLowerCase();
        if (firstWordFound) continue;
        var firstChar = allWords[i].substring(0, 1);
        if (!firstChar.match(/[a-z]/)) continue;
        allWords[i] = firstChar.toUpperCase() + allWords[i].substring(1);
        firstWordFound = true;
    }

    return allWords.join(' ');
}
2 Likes

Now yes, perfect, perfect, perfect, thank you a thousand times @lxp!!! :grinning: