DupeFinder opens ghost collection when called from a script

The Duplicate Finder selects a previously generated collection when called from a script. The correct collection must be selected from the dropdown to perform any further operations on it.

I made a small demo script DemoDupeFinder. Simply run it on a folder. Here the Finder shows a collection that was created two hours ago.

Before running the script above, I deleted all previous collections in the File Display and

/dopusdata\Collections
/dopuslocaldata\State Data\dupe.osd

and restarted Opus. No idea where the string was hiding :thinking:

javascript
function OnInit(initData) {
    initData.name = 'DemoDupeFinder';
    initData.version = '2023-11-13';
    initData.url = 'https://resource.dopus.com/t/dupefinder-opens-ghost-collection-when-called-from-a-script/46948';
    initData.desc = '';
    initData.default_enable = true;
    initData.min_version = '13.0';
}

function OnAddCommands(addCmdData) {
    var cmd = addCmdData.AddCommand();
    cmd.name = 'DemoDupeFinder';
    cmd.method = 'OnDemoDupeFinder';
    cmd.desc = '';
    cmd.label = '';
    cmd.template = '';
    cmd.hide = false;
    cmd.icon = 'script';
}

function OnDemoDupeFinder(scriptCmdData) {
    var cmd = scriptCmdData.func.command;
    var tab = scriptCmdData.func.sourcetab;
    var fsu = DOpus.FSUtil();

    cmd.deselect = false;

    if (tab.selected_dirs.count == 0) return;

    var item = tab.selected_dirs(0);

    var newColl = fsu.GetItem('coll://Dupes-' + DOpus.Create().Date().Format('A#yyyyMMdd-HHmmss'));
    cmd.RunCommand('CreateFolder NAME="' + newColl + '" READAUTO=tab,dual');

    var cmdLine = 'Find' +
        ' NAME=*' +
        ' DUPES' +
        ' MD5=cache' +
        ' CLEAR=no' +
        ' RECURSE=no' +
        ' COLLNAME="' + newColl.name + '"' +
        ' IN "' + item + '"';

    cmd.RunCommand(cmdLine);
    cmd.RunCommand('Set UTILITY=dupe');
}

CommandDemoDupeFinder.js.txt


Probably related: Duplicate Files issues

The main problem here is that your first command kicks off the duplicate finder with a particular configuration, and the second command opens the dupe finder panel, but the two things aren't actually connected in any way. The dupes panel is just opening up showing its previous settings without any link to the search that's currently running.

The issue in the other thread has been fixed so in the next beta, the way to achieve what you want would be to use FIND DUPES NOAUTORUN to configure and open the panel, instead of Set UTILITY, e.g. something like:

    var cmdLine = 'Find' +
        ' NAME=*' +
        ' DUPES' +
        ' MD5=cache' +
        ' CLEAR=no' +
        ' RECURSE=no' +
        ' COLLNAME="' + newColl.name + '"' +
        ' IN "' + item + '"';

    cmd.RunCommand(cmdLine);
	cmdLine += ' NOAUTORUN';
    cmd.RunCommand(cmdLine);
2 Likes

With NOAUTORUN Opus 13.0.51 now reliably opens the panel with the correct collection, but there are still 2.5 issues:

  • The Select button is greyed out. It will become active after either turning the panel off and on again or selecting a different collection from the drop-down and going back to the original one.

  • This second collection is also the second issue. It's either a generic "Duplicate Files" collection or one of the previously generated collections and will be there even when all old collections were deleted before running the script.

  • The last issue is more cosmetic/icing on the cake: Is there a way to not have a folder in the Find in section of the panel? If the collection is the result of a single Find command, the entry describes the collection well but is a bit confusing if the collection has been generated by more than one Find, like the Find Duplicates in Subfolders script.

We might try approaching this from a different way; in the next beta there'll be a RUNINPANEL argument. That will let you configure and show the panel and kick off the search all with the one command, exactly the same as clicking the Find button.

1 Like

With 13.2, I needed to go back to a version like the one you posted above. Using RUNINPANEL caused the problems described here.

Unfortunately, this brought back the issues from my Dec 6 post.

I'm finding all the different threads a but confusing, but it sounds like you're expecting RUNINPANEL to be synchronous, which it's not. As I said above, it's exactly like clicking the Find button. It'll start the find and return immediately.