ClipCopy (Copy stuff to the clipboard)

ClipCopy is a tool that copies information to the clipboard. Specific parameters determine the content to be copied. Last edit: 2024-04-13.

Parameters
COLUMNS Copies two sets of the current column setup in the syntax of Set COLUMNSTOGGLE and Set COLUMNSADD. The second set includes the current column width for easier editing. This can be directly pasted into a button to toggle columns or adjust the width. Useful to save setups and consolidate folder formats. Add BUTTON and you'll get XML code to be pasted to a toolbar.
NAMEANDCLOUDLINK Loops through selected items and checks their availability in cloud storage. Copies the names and links in separate lines. Useful if you want to distribute links to more than one item and don't want to start a clicking frenzy. Cloud storage often reacts slowly, so the script waits up to four seconds per item.

If you want to use Google Drive and your system's language is not English, you must pick the right language in the script. If your language is missing run ContextMenu SHOWCMDS on an item in Google Drive, look for the Label, and edit the script. Don't forget to share your findings!

Currently supported: Dropbox, Google Drive, OneDrive, Mega
NOLOG Append to suppress logging in the log panel
OSMLINK Creates http links to OpenStreetMap for all selected images that contain GPS data. Similar to what Image LOCATE=osm will create, but copied to the clipboard rather than launched in a browser.
QUICKFILTER Copies the current filter as a Set QUICKFILTER command. Add BUTTON and you'll get XML code to be pasted to a toolbar.
VALUES=<headerkey, ...> Copies the value of any available column. One line per item, separated by a tab. Add NOHEADING to suppress the first line. See below for details. :warning: Requires Opus 13.
WANIP Copies the system's public IP address.

The following parameters are kept for users of Opus 12. Opus 13 users can benefit from the greater flexibility of VALUES.

Parameters
DESCRIPTION Copies the description of all selected items. One line per item.
FILEASBITMAP Copies the first selected item via the viewer as a bitmap (not as a file). Useful to paste e.g. into Word documents.

Users of Opus 13 should choose Clipboard COPYIMAGE instead.
NAMEANDDESCRIPTION Copies name and description of all selected items. One line per item, separated by a tab.
NAMEANDPRODVERSION Copies name and product version of all selected items. One line per item, separated by a tab. Useful for .com, .exe, and .dll files.
NAMEANDSIZE Copies name and size in bytes of all selected items. One line per item, separated by a tab.
NAMEANDSIZEAUTO Copies name and size in bytes of all selected items. The size will be autoformatted by Opus standards (KB, MB, GB). One line per item, separated by a tab.
NAMEANDTARGET Copies the name and target of all selected items. One line per item, separated by a tab. Useful for .url and .lnk files.
TARGET Copies the target of all selected items. One line per item. Useful for .url and .lnk files.
TARGETPATH Like TARGET, but copies only the path part of the target.

How to set up

:one: Save CommandClipCopy.js.txt to   ↓

%appdata%\GPSoftware\Directory Opus\Script AddIns

:two: Copy this menu to a toolbar or create your own buttons with ClipCopy.

Menu as XML
<?xml version="1.0"?>
<button backcol="none" display="both" dropdown_glyph="yes" label_pos="right" textcol="none" type="menu">
	<label>ClipCopy</label>
	<icon1>#clipcopy</icon1>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Columns</label>
		<tip>Copies the current column setup</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy COLUMNS</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Description</label>
		<tip>Copies the description of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy DESCRIPTION</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>File as Bitmap</label>
		<tip>Copies the first selected items as a bitmap</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy FILEASBITMAP</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Cloudlink</label>
		<tip>Copies the names and links to cloud storage</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDCLOUDLINK</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Description</label>
		<tip>Copies name and description of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDDESCRIPTION</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Product Version</label>
		<tip>Copies name and product version of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDPRODVERSION</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Size</label>
		<tip>Copies name and size in bytes of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDSIZE</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Size (auto)</label>
		<tip>Copies name and size in bytes (autoformatted) of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDSIZEAUTO </instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Name and Target</label>
		<tip>Copies name and target of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy NAMEANDTARGET</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>OSM Link</label>
		<tip>Creates http links to OpenStreetmap for all selected images</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy OSMLINK</instruction>
		</function>
	</button>
    <button backcol="none" display="both" label_pos="right" textcol="none">
        <label>QuickFilter</label>
        <tip>Copy QuickFilter as command (Ctrl: as Button) to Clipboard</tip>
        <icon1>#clipcopy</icon1>
        <function type="normal">
            <instruction>@keydown:none</instruction>
            <instruction>ClipCopy QUICKFILTER</instruction>
            <instruction />
            <instruction>@keydown:ctrl</instruction>
            <instruction>ClipCopy QUICKFILTER BUTTON</instruction>
        </function>
    </button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Target</label>
		<tip>Copies the target of all selected items</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy TARGET</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Target (path)</label>
		<tip>Copies the target of all selected items (path only)</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy TARGETPATH</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>WAN IP</label>
		<tip>Copies the system&apos;s public IP address</tip>
		<icon1>#clipcopy</icon1>
		<function type="normal">
			<instruction>ClipCopy WANIP</instruction>
		</function>
	</button>
</button>

:three: (Optional) Add this button to the column header context menu. It will show a column's headerkey and can copy it to the clipboard. Useful when editing the list of columns for ClipCopy VALUES.

Button
@evalalways:hk=InStr(" ", headerkey)<0 ? headerkey : "" + headerkey + ""
@label:Format(original_label, hk)
Clipboard SET={=hk=}
<?xml version="1.0"?>
<button backcol="none" display="label" label_pos="right" separate="yes" textcol="none">
	<label>Copy &lt;b&gt;%1&lt;/b&gt; to Clipboard</label>
	<icon1>#newcommand</icon1>
	<function type="normal">
		<instruction>@evalalways:hk=InStr(&quot; &quot;, headerkey)&lt;0 ? headerkey : &quot;&quot; + headerkey + &quot;&quot;</instruction>
		<instruction>@label:Format(original_label, hk)</instruction>
		<instruction>Clipboard SET={=hk=}</instruction>
	</function>
</button>

How to use

ClipCopy VALUES lets you create your own set of columns whose values get copied to the clipboard. The command understands the column keywords ("headerkey"). They must be separated by commas. If they contain a space (some script columns might), enclose them in quotes. The first line of the output will be a heading unless it gets suppressed with NOHEADING. The columns don't need to be visible to be copied.

Examples:

ClipCopy VALUES=name,comments
ClipCopy VALUES=name,eval:modifiedsimple
ClipCopy VALUES=name,type,target NOHEADING
ClipCopy VALUES=name,modified,scp:ExifTool/EXIF-ExifImageHeight,scp:ExifTool/EXIF-ExifImageWidth
ClipCopy VALUES=name,"scp:MyScript/Column with Spaces"

Things you might enjoy reading

How to use buttons and scripts from this forum

ClipCopy's siblings are ClipEdit and ClipPaste.

The script's inner workings

JScript
function OnInit(initData) {
    initData.name = 'ClipCopy';
    initData.version = '2024-04-13';
    initData.url = 'https://resource.dopus.com/t/clipcopy-copy-stuff-to-the-clipboard/44626';
    initData.desc = 'Copy various information to the clipboard';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

function OnAddCommands(addCmdData) {
    var cmd = addCmdData.AddCommand();
    cmd.name = 'ClipCopy';
    cmd.method = 'OnClipCopy';
    cmd.template = '' +
        'button/s,' +
        'columns/s,' +
        'description/s,' +
        'fileasbitmap/s,' +
        'nameandcloudlink/s,' +
        'nameanddescription/s,' +
        'nameandprodversion/s,' +
        'nameandsize/s,' +
        'nameandsizeauto/s,' +
        'nameandtarget/s,' +
        'noheading/s,' +
        'nolog/s,' +
        'osmlink/s,' +
        'quickfilter/s,' +
        'target/s,' +
        'targetpath/s,' +
        'values/k,' +
        'wanip/s';

    cmd.hide = false;
    cmd.icon = 'script';
}

function OnClipCopy(scriptCmdData) {
    var cmd = scriptCmdData.func.command;
    var tab = scriptCmdData.func.sourcetab;
    var args = scriptCmdData.func.args;
    var argsmap = scriptCmdData.func.argsmap;

    cmd.deselect = false;

    var tmp = '';

    if (false);
    else if (args.columns) CopyColumns();
    else if (args.description) CopyDescription();
    else if (args.fileasbitmap) CopyFileAsBitmap();
    else if (args.nameandcloudlink) CopyNameAndCloudlink();
    else if (args.nameanddescription) CopyNameAndDescription();
    else if (args.nameandprodversion) CopyNameAndProdversion();
    else if (args.nameandsize) CopyNameAndSize();
    else if (args.nameandsizeauto) CopyNameAndSizeAuto();
    else if (args.nameandtarget) CopyNameAndTarget();
    else if (args.osmlink) CopyOsmLink();
    else if (args.quickfilter) CopyQuickFilter();
    else if (args.target) CopyTarget();
    else if (args.targetpath) CopyTargetPath();
    else if (args.values) CopyValues();
    else if (args.wanip) CopyWanIp();

    if (tmp) {
        DOpus.SetClip(tmp);
    } else {
        tmp = '<<< Clipboard has not been changed >>>';
    }

    Log(tmp);

    // ====

    function CopyColumns() {
        var colNames = '';

        for (var e = new Enumerator(tab.format.columns); !e.atEnd(); e.moveNext()) {
            var colName = e.item().name;
            if (colNames) colNames += ', ';
            colNames += colName;
            if (colName == 'name') continue;

            if (tmp) tmp += '\r\n';
            tmp += 'Set COLUMNSTOGGLE="' + colName + '(!,a,0)"';
        }

        tmp += '\r\n';
        tmp += '\r\n';

        for (var e = new Enumerator(tab.format.columns); !e.atEnd(); e.moveNext()) {
            if (tmp) tmp += '\r\n';
            tmp += 'Set COLUMNSADD="' + e.item().name + '(!,' + e.item().width + ',' + e.item().max + ')"';
        }

        if (args.button) {
            var arr = tmp.split('\r\n');
            tmp = '';
            tmp += '<?xml version="1.0"?>' + '\r\n';
            tmp += '<button backcol="none" display="both" hotkey_label="yes" label_pos="right" textcol="none">' + '\r\n';
            tmp += '    <label>Set COLUMNS</label>' + '\r\n';
            tmp += '    <tip>' + colNames + '</tip>' + '\r\n';
            tmp += '    <icon1>#set</icon1>' + '\r\n';
            tmp += '    <function type="normal">' + '\r\n';

            for (var i = 0; i < arr.length; i++) {
                tmp += '        <instruction>' + arr[i].replace(/"/g, '&quot;') + '</instruction>' + '\r\n';
            }

            tmp += '    </function>' + '\r\n';
            tmp += '</button>' + '\r\n';
        }
    }

    function CopyDescription() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp) tmp += '\r\n';
            tmp += item.metadata.other.autodesc;
        }
    }

    function CopyFileAsBitmap() {
        if (!tab.selected.count) return;
        var item = tab.selected(0);
        cmd.RunCommand('Show FILE="' + item + '" USEEXISTING=no');
        var newVwrs = cmd.results.newviewers;
        newVwrs(0).Command('selectall');
        newVwrs(0).Command('copy');
        newVwrs(0).Command('close');
    }

    function CopyNameAndCloudlink() {
        DOpus.Output('Enumerating...');
        DOpus.Output('');

        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            DOpus.Output(item);
            tmp += item.name + '\r\n';
            var linkFound = false;

            GetCloudLink('VERB="{3340B3D7-438C-4FC9-81BF-8D9D81B05730}"'); //      Dropbox
            GetCloudLink('VERB="{5250E46F-BB09-D602-5891-F476DC89B702}"'); //      OneDrive
            GetCloudLink('VERB="GetMEGALink"'); //                                 Mega

            // Pick the language that fits your system                             Google Drive
            GetCloudLink('LABEL="Copy link to clipboard"');
            // GetCloudLink('LABEL="Copia link negli appunti"');
            // GetCloudLink('LABEL="Copiar enlace en el portapapeles"');
            // GetCloudLink('LABEL="Copier le lien dans le presse-papiers"');
            // GetCloudLink('LABEL="Link in die Zwischenablage kopieren"');

            if (!linkFound) tmp += 'No cloud link found\r\n';
            tmp += '\r\n';
        }

        DOpus.Output('');
        DOpus.Output('... done!');
        DOpus.Output('');

        function GetCloudLink(menuCommand) {
            DOpus.SetClip();
            cmd.RunCommand('ContextMenu' +
                ' ITEMMODE' +
                ' FILE="' + item + '"' +
                ' ' + menuCommand);

            for (var i = 0; i < 20; i++) {
                DOpus.Delay(100);
                var clipText = DOpus.GetClip();
                if (!clipText) continue;
                tmp += clipText + '\r\n';
                linkFound = true;
                break;
            }

            DOpus.Output((clipText ? clipText : '*** none') + ' (Number of wait loops: ' + i + ')');
        }
    }

    function CopyNameAndDescription() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp) tmp += '\r\n';
            tmp += item.name + '\t' + item.metadata.other.autodesc;
        }
    }

    function CopyNameAndProdversion() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp) tmp += '\r\n';
            tmp += item.name + '\t' + item.metadata.exe.prodversion;
        }
    }

    function CopyNameAndSize() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (tmp) tmp += '\r\n';
            tmp += item.name + '\t' + item.size;
        }
    }

    function CopyNameAndSizeAuto() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (tmp) tmp += '\r\n';
            tmp += item.name + '\t' + item.size.fmt;
        }
    }

    function CopyNameAndTarget() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp) tmp += '\r\n';
            tmp += item.name + '\t' + item.metadata.other.target;
        }
    }

    function CopyOsmLink() {
        var zoomlevel = 18;
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            var lat = item.metadata.image.latitude;
            if (typeof lat != 'number') continue;
            var lon = item.metadata.image.longitude;
            if (typeof lon != 'number') continue;
            if (tmp) tmp += '\r\n';
            tmp += 'https://www.openstreetmap.org/?' +
                '&mlat=' + lat +
                '&mlon=' + lon +
                '#map=' + zoomlevel + '/' + lat + '/' + lon;
        }
    }

    function CopyQuickFilter() {
        var evalMode = cmd.IsSet('Set QUICKFILTERFLAGS=evalon');
        var reMode = cmd.IsSet('Set QUICKFILTERFLAGS=regexpon');
        var quickFilter = tab.quickfilter.filter;

        var cmdLine = 'Set' +
            ' QUICKFILTERFLAGS=eval' + (evalMode ? 'on' : 'off') + ',regexp' + (reMode ? 'on' : 'off') +
            ' QUICKFILTER="' + quickFilter.replace(/"/g, '""') + '"';

        if (args.button) {
            tmp += '<?xml version="1.0"?>' + '\r\n';
            tmp += '<button backcol="none" display="both" hotkey_label="yes" label_pos="right" textcol="none">' + '\r\n';
            tmp += '    <label>QF</label>' + '\r\n';
            tmp += '    <tip>' + quickFilter + '</tip>' + '\r\n';
            tmp += '    <icon1>#filterfolder</icon1>' + '\r\n';
            tmp += '    <function type="normal">' + '\r\n';
            tmp += '        <instruction>' + cmdLine.replace(/"/g, '&quot;') + '</instruction>' + '\r\n';
            tmp += '    </function>' + '\r\n';
            tmp += '</button>' + '\r\n';
        } else {
            tmp = cmdLine;
        }
    }

    function CopyTarget() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp) tmp += '\r\n';
            tmp += item.metadata.other.target;
        }
    }

    function CopyTargetPath() {
        for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (item.metadata == 'none') continue;
            if (tmp) tmp += '\r\n';
            tmp += item.metadata.other.target.pathpart;
        }
    }

    function CopyWanIp() {
        var xhr = new ActiveXObject('MSXML2.XMLHTTP');
        var urlIpCheck = 'https://checkip.amazonaws.com';

        xhr.open('GET', urlIpCheck, false);
        xhr.send();

        tmp = xhr.status == 200 ? xhr.responseText.replace(/[^.0-9]/g, '') : 'HTTP STATUS: ' + xhr.status;
    }

    function CopyValues() {
        if (!DOpus.version.AtLeast('13')) {
            DOpus.Output('Sorry, ClipCopy VALUES requires Opus 13.');
            return;
        }

        DOpus.vars.Set('columnValue', '');

        var argValues = args.values;
        argValues = argValues.replace(/,+/g, ',');
        argValues = argValues.replace(/^,|,$/g, '');
        if (!argValues) argValues = 'name';

        var arr = argValues.split(',');

        var cmdLine = '';

        for (var i = 0; i < arr.length; i++) {
            if (cmdLine) cmdLine += '+"\t"+';
            cmdLine += 'Val("' + arr[i] + '")';
        }

        cmdLine = 'Select' +
            ' FILTERDEF' +
            ' =$glob:columnValue+=' + cmdLine + '+"\r\n"' + ';false';

        cmd.RunCommand('Select INVERT');
        cmd.RunCommand(cmdLine);
        cmd.RunCommand('Select INVERT');

        if (!args.noheading) tmp = argValues.replace(/,/g, '\t') + '\r\n';

        tmp += DOpus.vars.Get('columnValue');
    }

    function Log(str) {
        if (args.nolog) return;
        cmd.RunCommand('Set UTILITY=scriptlog');
        // DOpus.ClearOutput();
        DOpus.Output('\n' + str);
    }
}
10 Likes

Cool. Can you add a MEGA cloud support, please? and may be some changes to output size format? auto KB, MB??

Try adding this as line 103:

            GetCloudLink('Get MEGA link'); //          Mega

For which command? ClipCopy NAMEANDSIZE?

Yes

it's an item in drop down menu. must be changed according to MEGA's language
thank you

Update 2023-06-14

  • Added support for Mega cloud storage.
  • Added ClipCopy NAMEANDSIZEAUTO which autoformats the size (KB, MB, GB).
2 Likes

thanx
u're forgot to change CommandClipCopy.js.txt - there's an old version))

Oops :blush:

(As they always say... don't post and talk...)

Could you please add a command for the target path (TARGET, but without file name)?

Update 2023-06-15

  • Added ClipCopy TARGETPATH which copies only the path part of the target.
1 Like

Thanks a lot.
Using Settings > File Types, I've added this as a context menu entry.

It's such a gread addin! I'm sure I will use several of its commands in the future.

I'm curious... Would it be possible to have command that leads to a different result depending on the selected object? Eg. Copying the target path when a lnk is selected, but when a different file is selected, copying the folder path instead. Note that I'm not requesting this (I don't need this in my workflow), I'm just curious if it would be possible. :thinking:

Absolutely. No limits :slight_smile:

1 Like

Hi Ixp,
Thanks for directing me to this thread. I think I may have set up ClipCopy incorrectly...

I saved the CommandClipCopy.js.txt to the AppData folder. Then I got rid of the ".txt" Also I pasted the XML code into my toolbar. The ClipCopy dropdown menu on the toolbar looks right, but I'm getting the "... cannot find ..." error as seen in the image...

Any ideas where I went wrong?

Well, that's odd. Is the script activated in the dialog?

Does it show up in a button?

Move "CommandClipCopy.js" one level up into "Script AddIns". CLI is the wrong folder.

2 Likes

Thank you both. My Script Management window was totally empty, so I redownloaded the file, and used that dialog to install it. It is indeed in the 'Script Addins' folder now. :slight_smile:

1 Like

Update 2024-03-04

  • COLUMNS additionally outputs a set of Set COLUMNSADD commands that include the current column width for easier editing.
  • Added QUICKFILTER. It copies the current filter as a Set QUICKFILTER command. Add BUTTON and you'll get XML code to be pasted to a toolbar.
1 Like

Update 2024-04-13

  • COLUMNS now supports BUTTON to get XML code ready to be pasted to a toolbar.
  • QUICKFILTER now includes the state of "use regular expression".
  • Added VALUES. Copies the value of any available column. Supports an unlimited number of columns. Similar to Print FOLDER and Clipboard COPYNAMES COPYCOLUMNS but with programmatic control of the column selection.
1 Like