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