jhn
July 5, 2020, 4:17pm
1
Hi,
I'm looking for a way to select files by grabbing names from the clipboard.
Let's say I have a CSV like clipboard entry: IA4BTO4GG, IA3WKT40K, IA4BU64FX, IA3WKTG4F
Now I want to make a button or anything that will look into the current view (either a folder or a flat view) and select or filter these 4 items. What would be the best approach for this?
Thanks!
-Johan
lxp
July 5, 2020, 5:43pm
2
Two quick hacks.
Select
function OnClick(clickData) {
if (DOpus.GetClipFormat() != 'text') return;
var cmd = clickData.func.command;
var tab = clickData.func.sourcetab;
cmd.deselect = false;
var items = DOpus.GetClip().split(', ') || [];
cmd.ClearFiles();
for (var i = 0; i < items.length; ++i) {
cmd.AddFile(tab.path + '\\' + items[i]);
}
cmd.RunCommand('Select FROMSCRIPT SETFOCUS');
}
CSV Select From Clipboard.dcf (1.1 KB)
Filter
function OnClick(clickData) {
if (DOpus.GetClipFormat() != 'text') return;
var cmd = clickData.func.command;
var filter = '"(' + DOpus.GetClip().replace(/, /g, '|') + ')"';
cmd.RunCommand('Set QUICKFILTER=' + filter);
}
QuickFilterFromClipboard.dcf (741 Bytes)
This post explains how to add buttons to toolbars and menus, and also applies to raw commands for things like standalone hotkeys.
For how to use Script Add-Ins, please scroll down to see the post below this one.
Much of this assumes Directory Opus…
2 Likes
jhn
July 7, 2020, 1:47pm
3
This is awesome stuff, I will implement it asap and report back.
Thanks a lot!