Hide duplicate groups when they're only within a single root folder

I know duplicates have been discussed a lot before but I'm facing a somewhat specific scenario:


  • Folder 1 = "C:\Testdata\1"
    has many duplicates within itself. I don't want to display or visually compare those.

  • Folder 2 = "C:\Testdata\2\Verified"
    has no duplicates among itself but has some duplicates in Folder1.

I need to display duplicate groups only when they have members in BOTH Folder1 and Folder2.

An elegant way would be for an option to ignore duplicates nested within the roots if multiple folders are added to the find dialog.

Scripting sounds like it can do the job though so here's my attempt.
In this example we only want dupe groups which contain at least one item from Folder 2 - so we match containing "verified" in their path.

function OnClick(clickData) {

    var cmd = clickData.func.command;
    var wildcard = "verified";
    cmd.deselect = true;

    for (var groups = new Enumerator(clickData.func.sourcetab.filegroups); !groups.atEnd(); groups.moveNext()) {
        var thisGroup = groups.item();
        var hasTargetFiles = false;

        //loop files
        for (var members = new Enumerator(thisGroup.members); !members.atEnd(); members.moveNext()) {
            var file = members.item();
            if (String(file).toLowerCase().includes(wildcard)) {
                hasTargetFiles = true;
                DOpus.Output("Match on " + file);

        //hide by default if no items match
        if (!hasTargetFiles) {
            cmd.AddLine('Select "' + thisGroup + '" GROUPNAME HIDESEL');

    //run queued commands
    if (cmd.linecount > 0)

if (!String.prototype.includes) {
    String.prototype.includes = function (search, start) {
        'use strict';

        if (search instanceof RegExp) {
            throw TypeError('first argument must not be a RegExp');
        if (start === undefined) { start = 0; }
        return this.indexOf(search, start) !== -1;

Perhaps I have the wrong approach to the problem but with the solution I came up with here's what happens.

  1. Enumerating groups goes fine.

  2. Problem 1:
    Trying to enumerate the resulting group.members property returns an integer in DOpus.Output instead of a collection of files which can then be enumerated. Am I approaching the enumeration wrong?
    Thus hasTargetFiles is always false and all groups are set to be hidden.
    Even if all groups are hidden now we come to:

  3. Problem 2:
    Selecting groups by Name which involves wildcard parsing of a string seems inefficient.
    Since we already have a group.ID property why not support that like

Select thisGroup.id GROUPID HIDESEL
  1. Problem 3:
    Even using the command queue makes hiding take forever on long duplicate lists.
    Is there any way to make the HIDE all at once?
    With something like cmd.AddGroup (similar to cmd.AddFile) for example?

Another way I see it is to use cmd.AddFile on the group members themselves and not act on the groups at all.