GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Display or select unique or distinct files

Hi have not found a way to display only unique files in a search / find or any other display that presents many files maybe in different directories and are the same files.
In this way I am able to check/view only one of the files per set.
If the display shows 40 files and of them 20 are repeats then I would like a button or something to display only the distinct ones (file name difference only).

If you are looking at a Find Results collection, this button will remove from the collection all files that have the same file name as a previous item:

Note: This only works with Find (e.g. Tools > Find Files). It won't work with Windows Search (e.g. the field at the top right of the lister), as you can't modify the results of a Windows Search query after it has been run, other than by modifying the query and running it again.

Script code for reference:

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

	var names = DOpus.Create.StringSetI();

	for (var eSel = new Enumerator(clickData.func.sourcetab.files); !eSel.atEnd(); eSel.moveNext())
	{
		var item = eSel.item();
		if (!names.insert(item.name))
		{
			cmd.AddFile(item);
		}
	}

	cmd.RunCommand("Delete REMOVECOLLECTION");
}

Thanks!