Compare directories based on first part of filename

Yes, with a little script.

The two directories should be source and destination. The script will loop through the source and check for files in the destination.

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    var dtab = clickData.func.desttab;
    var fsu = DOpus.FSUtil();
    var dlg = clickData.func.Dlg();

    cmd.deselect = false;
    cmd.RunCommand('Set UTILITY=otherlog');
    DOpus.ClearOutput();

    var srcPath = String(tab.path);
    var dstPath = String(dtab.path);

    DOpus.Output('Source:      ' + srcPath);
    DOpus.Output('Destination: ' + dstPath);

    if (tab.path.drive == 0 || dtab.path.drive == 0) {
        dlg.Request('Please select suitable drives for source and destination!', 'OK');
        return;
    }

    if (srcPath == dstPath) {
        dlg.Request('Please select different folders for source and destination!', 'OK');
        return;
    }

    DOpus.Output('\nEnumerating...\n');

    var folderEnum = fsu.ReadDir(tab.path, 'r');
    while (!folderEnum.complete) {
        var item = folderEnum.Next();
        if (item.is_dir) continue;
        var itemToCheck = String(item.realpath).replace(srcPath, dstPath) + '.tags.txt';
        if (fsu.Exists(itemToCheck)) continue;
        DOpus.Output(itemToCheck);
    }
    DOpus.Output('\n... done!');
}

Find Missing Files In Tree.dcf (2.6 KB)


4 Likes