Compare directories based on first part of filename

I want to compare 2 directories, these directory adhere the following criteria:

  1. both directories contain the same directory structure
  2. both directories should contain filenames with the same prefix.

First directory contains

  • dir1
    • file1.flac
    • flle2.flac
  • dir2
    • file3.flac
    • flle4.flac

Second directory contains

  • dir1
    • file1.flac.tags.txt
    • flle2.flac.tags.txt
  • dir2
    • flle4.flac.tags.txt

The compare should indicate that dir2/file3.flac.tags.txt is missing.

Can I do this with OPUS?

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');

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

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

    if ( == 0 || == 0) {
        dlg.Request('Please select suitable drives for source and destination!', 'OK');

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


    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('\n... done!');

Find Missing Files In Tree.dcf (2.6 KB)


Awesome! I appreciate the time and effort you invested in creating this script to help me out. It points me in the good direction, I'm able to adapt the script so it fits my needs. The link to the additional how to was also very helpful. Thanks again lxp :+1:

Nice program too Directory Opus!