GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Uppercase Range

Overview

This preset asks for a start position and length, then converts the specified region of the file name into upper case.

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:

2020-04-02 00-20-36 Clipboard Image

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.

Preset / Download

Here's the rename preset:

Script Code

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";
}