Multiple file and inline rename

I've been using the script above to see if any problems arise from it, with a view to potentially making it the new default.

One problem I ran into is that it breaks F2 to rename items in the folder tree.

This is fixed in the version below.

The new part is the if (cmd.IsSet("focus=tree")) { ... } block near the start.

It requires 12.9.2 beta or above.

function OnClick(clickData)
{
	var cmd = clickData.func.command;

	if (cmd.IsSet("focus=tree"))
	{
		cmd.deselect = false;
		cmd.ClearFiles();
		cmd.RunCommand("Rename INLINE");
		return;
	}

	var selected = clickData.func.sourcetab.selected;
	var count = selected.count;

	if (count == 0)
		return;

	if (count == 1)
	{
		cmd.RunCommand("Rename INLINE");
		return;
	}

	var dlg = clickData.func.Dlg();
	dlg.title = "Rename - Directory Opus";
	dlg.message = "Enter new name for all " + count + " items:";
	dlg.buttons = "&OK|&Cancel";
	dlg.max = 0;
	dlg.defvalue = selected(0).name_stem_m;
	dlg.icon = "question";
	dlg.select = true;

	if (dlg.Show() != 1)
		return;

	var newName = String(dlg.input);

	if (newName == "")
		return;

	newName = newName.replace(/"/g, "'");

	var cmdLine = 'Rename AUTORENAME IGNOREEXT PATTERN="*" TO="' + newName + '"';

	cmd.RunCommand(cmdLine);
}