Rename only works if I click "run" twice

Give this a try, changing the last line to run the rename preset you want:

function OnClick(clickData)
{
	// Change ".all" to ".files" if you only want files.
	var items = clickData.func.sourcetab.all;

	// If skipNext is true, will do even items. Else odd items.
	var skipNext = false;

	var cmd = clickData.func.command;
	cmd.deselect = false;
	cmd.ClearFiles();

	for (var e = new Enumerator(items); !e.atEnd(); e.moveNext())
	{
		if (skipNext)
		{
			skipNext = false;
			continue;
		}
		skipNext = true;
		cmd.AddFile(e.item());
	}

	if (cmd.filecount == 0)
		return;
	cmd.RunCommand('Rename PRESET="presetX"');
}

Test on some backup files first, of course!

1 Like