The Rename dialog already has built-in options to modify the case of the whole filename, or every word, and similar, if you need that instead. This preset is only useful if you want to uppercase a specific part of the filenames by position and length.
Two extra fields are added to the Rename dialog so you can specify the position and length to uppercase:
The Uppercase Position value starts at zero. If you wanted to uppercase the first five characters, you would set Position = 0 and Length = 5.
The Uppercase Length value can be longer than the names (it's 999 by default) if you want to uppercase everything from the position to the end of the names.
The file extension is always left as-is, but you can use the Modify Capitalization option in the Rename dialog to affect that at the same time if you wish.
Here's the full script code inside the preset, for reference:
function OnGetNewName(getNewNameData)
{
var name = getNewNameData.newname_stem_m;
var ext = getNewNameData.newname_ext_m;
var pos = getNewNameData.custom.pos;
var len = getNewNameData.custom.len;
if (name.length > pos)
{
var A = name.substr(0,pos);
var B = name.substr(pos,len);
var C = name.substr(pos+len);
name = A + B.toUpperCase() + C;
}
return name + ext;
}
function OnGetCustomFields(getFieldData)
{
getFieldData.fields.pos = 0;
getFieldData.fields.len = 999;
getFieldData.field_labels("pos") = "Uppercase Position";
getFieldData.field_labels("len") = "Uppercase Length";
}
That would run the preset as-is without opening the rename dialog. Add the ADVANCED argument if you want the dialog to open at the same time as specifying a preset to use.
After add the ADVANCED argument it's work.
It's work via Rename dialog box, but That would be better If the script can produce a little dialog box it self where we can input the Uppercase Position & Uppercase Length
Hello Leo, I know this is a fairly "new" post (i.e., less than five years), but I was wondering how to create a Rename that has exceptions. More specifically, this has to do with capitalizing words. When Titles are involved, we do not capitalize all the words. For example, if not at the beginning of a title (i.e., file name), the following words should appear lower case.
a
an
and
as
at
by
for
in
If I know how the script is done for Capitalize All Words in Rename (I am not a programmer...I dabble), I may be able to create how to add the exceptions. I have a list of at least 29 words that would not be capitalized if found within (i.e., not at beginning) a file name.