Select files that contain name similar to the selected file

Works for what was specified. The extra detail should have been in the question. :slight_smile:

This should cover what you're now asking for:

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	cmd.deselect = false; // Prevent automatic deselection
	if (clickData.func.sourcetab.selected.count == 0)
		return; // Nothing selected.
	var name = clickData.func.sourcetab.selected(0).name+"";
	var pat = name.replace(/^([^\.]+)\..*/, "$1");
	if (name == pat)
		return; // Name doesn't match the pattern.
	// EscapeString, in case the name contains pattern-matching characters.
	pat = DOpus.FSUtil.NewWild.EscapeString(pat);
	// Change .* to * if the dot is meant to be optional in the other files:
	var cmdLine = 'Select PATTERN="' + pat + '.*"';
//	DOpus.Output(cmdLine);
	cmd.RunCommand(cmdLine);
}

To use the script on a toolbar button: How to use buttons and scripts from this forum - #2 by Leo

2 Likes