Select or filter given filename

I want to select a single file in a folder and then subsequently select the remaining files in that folder that match a previously configured filter.

I have a filter defined as "LaTeX aux-tmp" ="*.(aux|toc|log)" and these files:

test1.tex
test2.tex
test1.aux
test2.aux
test1.toc
test2.toc
test1.log
test2.log
test1.pdf
test2.pdf

and I want to be able to select a single file, like test2.toc, then have a button that would then select only these with the asterisks:

test1.tex
test2.tex
test1.aux
test2.aux **
test1.toc
test2.toc **
test1.log
test2.log **
test1.pdf
test2.pdf

so that I can delete them and then clear the filter.

I have a button defined as Select "LaTeX aux-tmp" FILTER, but then i have to deselect those that don't share the stem.

You could do it using a script like this:

function OnClick(clickData)
{
	if (clickData.func.sourcetab.selected.count != 1)
		return;

	nameStem = clickData.func.sourcetab.selected(0).name_stem_m.toLowerCase();
	DOpus.Output(nameStem);

	var cmd = clickData.func.command;
	cmd.ClearFiles();
	cmd.RunCommand('Select "LaTeX aux-tmp" FILTER');

	clickData.func.sourcetab.update();

	var needToDeselect = false;
	for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())
	{
		var item = eSel.item();
		if (item.name_stem_m.toLowerCase() !== nameStem)
		{
			cmd.AddFile(item);
			needToDeselect = true;
		}
	}

	if (needToDeselect)
	{
		cmd.RunCommand("Select DESELECT FROMSCRIPT");
	}
}

If the filter was inverted, so it matches everything except *.(aux|toc|log) then the script would not be needed as it could be done with two more simple commands. Similarly if you put the wildcard directly in the button rather than use a filter. But the above method is probably what you want if you want to use a filter and don't want to invert it or maintain a second filter that is inverted.

Nice! Thank you very much and thank you for the additional explanation. That was, as always, very helpful.