Button to Copy product version?

Hello,

is it possible to create a button which would copy the Name and Product version of the selected files ?

I know we can do it manually with the Print Folder option, but I'm trying to do it more quickly for the selected files only.

The following doesn't work, but this is just to show what could have been working :slight_smile:
Clipboard SET {allfile|prodversion}

Is there any way to do it ?

A script could do it fairly easily, but I don't think there's a way to do it from a single-line command.

Try

function OnClick(clickData) {
    var tab = clickData.func.sourcetab;

    var result = '';
    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        result += item.name + ' ' + item.metadata.exe.prodversion + '\n';
    }

    if (result == '') return;

    DOpus.SetClip(result);
}

ClipboardCopyNameProdversion.dcf (1004 Bytes)


Hello,

I can finally get back to you about the script.

when you posted it, I tried right away, however it didn't seem to work, I couldn't get the result in the clipboard and I had some error in the script output logs.

I meant to try again and give you some feedback but then other tasks came up and it got delayed.

Today, I tried again and it seems to be working. I can't remember how I got all the errors previously.

However I have managed to produce an error while trying to get the DLL version of a system file:
C:\Windows\System32\argtmp39.dll

The error is:
29/12/2020 16:32 Error at line 7, position 9
29/12/2020 16:32 'metadata.exe.prodversion' is null or not an object (0x800a138f)

I can't remember if it was exactly the same error last time and the same file... but it was pretty similar.

Do you know how to prevent this ?
(the file is displayed as a system file and is color coded in red in Directory Opus, this is the only DLL file looking like that, and the only DLL file giving an error.)

That's odd... the script should simply return undefined, if prodversion does not exist.

Well, try this. Untested, as I don't have that DLL on my system.

function OnClick(clickData) {
    var tab = clickData.func.sourcetab;

    var result = '';
    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        if (typeof item.metadata.exe != 'object') continue;
        result += item.name + ' ' + item.metadata.exe.prodversion + '\n';
    }
    if (result == '') return;

    DOpus.SetClip(result);
}

thank you for your quick answer, I have tested and it works.
It skips the file completely though and doesn't mention it at all in the output.

For this type of files, is there a way to keep the file name and add 'undefined' instead of the product version ? (I tried a few things, but I end up with only this file name in my results and not the other names)

function OnClick(clickData) {
    var tab = clickData.func.sourcetab;

    var result = '';
    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        result += item.name + ' ' + (typeof item.metadata.exe == 'object' ? item.metadata.exe.prodversion : 'undefined') + '\n';
    }
    if (result == '') return;

    DOpus.SetClip(result);
}

From the filename, that file looks like a temporary file, possibly there until you reboot next. It may not be readable at all.

Hello,

it works perfectly, thank you :+1: :+1: :+1: