GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Commands to copy selected filenames to the clipboard


#1

Clipboard commands in the default configuration:

Directory Opus comes pre-configured with menu items and hotkeys for copying the names and/or paths of selected items to the clipboard.

In the default Edit menu:

In the default right-click context menus:

You can move those around, modify their hotkeys, or add more commands for doing slightly different things.

Adding similar commands to right-click context menus:

If your right-click context menus are missing the default commands, or if you want to add extra commands to them, here is how. We will add the basic Copy File Names item, but you can modify things as needed.

  • In Opus, click Settings > Filetypes...
  • Double-click All Files & Folders, near the top of the list.
  • Select the Context Menu tab.
  • Click New
  • Enter the following information for the new filetype action:
    Action: Copy Names
    Type: Run an Opus function (not supported in Explorer)
    Function: Clipboard COPYNAMES
    (If you click the square next to the action's name, you can also give it an icon if you wish.)
  • Click OK twice to save your changes, then Close to close the Filetypes editor.

If you now select and right-click some files in Opus, you'll find the new command in the context menu.

Specifying what gets put in the clipboard:

You can add arguments to the command to change what is put in the clipboard. For example, you may only want the filenames and not the paths, or you might want UNC paths for files on mapped network drives (since other people may map them via a different drive-letter).

Below are some examples. Refer to the Clipboard command in the manual for full details.

  • Default:
    CLIPBOARD COPYNAMES
    H:\Example_Filename.jpg

  • Filename Only:
    CLIPBOARD COPYNAMES=nopaths
    Example_Filename.jpg

  • Short Paths:
    CLIPBOARD COPYNAMES=short
    H:\EXAMPL~1.JPG

  • URL:
    CLIPBOARD COPYNAMES=url
    file://H:\Example%5fFilename.jpg

  • UNC (network drives):
    CLIPBOARD COPYNAMES=unc
    \\marla\share\Example_Filename.jpg

  • MD5 hash (1):
    CLIPBOARD COPYNAMES=hash
    Example_Filename.jpg : 1224d22982530cde353aa7f6a090ef55

  • MD5 hash (2):
    CLIPBOARD COPYNAMES=hash2
    1224d22982530cde353aa7f6a090ef55 *Example_Filename.jpg

You can use single to make everything appear on a single line instead of one line per file. You can also combine things, for example:

  • Copy the short names, without paths, to a single line:
    Clipboard COPYNAMES=short,nopaths,single

Applying Regular Expressions to the paths:

You can modify what gets placed in the clipboard using regular expressions. Below are some examples. (See RegExp basics: Removing characters from start/end of names if you need help learning the basics of regular expressions.)

  • Copy UNC path with quotes around it:
    Clipboard COPYNAMES=unc REGEXP (.*) ""\1""
    "\\marla\share\Example_Filename.jpg"

  • Copy file names without extensions:
    Clipboard COPYNAMES=nopaths REGEXP (.*)\.[^.]* \1
    H:\Example_Filename

  • Copy paths escaped for C++:
    See separate example.
    \\\\marla\\share\\Example_Filename.jpg

Putting the current folder's path in the clipboard:

To re-create the Folder Path item in the default config, see the separate thread, Copy the current path to the clipboard.

Copy the whole folder listing to the clipboard:

To re-create the Complete Folder Listing item in the default config:

  • Complete Folder Listing:
    Print FOLDER AS=txt TO=clip FLATVIEW=no QUIET

Scripting, for more esoteric needs

For more complicated or esoteric requirements, where the built-in modes and/or regular expressions aren't enough, you can use a script.

For example:


JScript:

function OnClick(clickData)
{
	clickData.func.command.deselect = false;
	tab = clickData.func.sourcetab;

	if (tab.selected.count == 0)
	{
		// Nothing selected? Do the whole folder.
		NamesToClipboard(tab.dirs, tab.files);
	}
	else
	{
		// Something selected? Do just the selection.
		NamesToClipboard(tab.selected_dirs, tab.selected_files);
	}
}

function NamesToClipboard(dirs, files)
{
	s = "";

	for (var eDirs = new Enumerator(dirs); !eDirs.atEnd(); eDirs.moveNext())
	{
		// Directory names as-is.
		s += eDirs.item().name;
		s += "\n"; // Each name on a new line.
	}

	for (var eFiles = new Enumerator(files); !eFiles.atEnd(); eFiles.moveNext())
	{
		// File names excluding extensions.
		s += eFiles.item().name_stem_m;
		s += "\n"; // Each name on a new line.
	}

	DOpus.SetClip(s);
}

Copy the current path to the clipboard
How can I create a path+file name list of selected directori
How can I create a path+file name list of selected files?
Problem adding file to clipboard
How to copy path to clipboard?
MD5 in Context Menu
Right click COPYNAMES lost
Copy selected filenames as URL including UNC?
Copy selected filenames to clipboard - from FTP
How to copy files names without extend name?
Copy part or all of a file name
Selecting the extention when copying a file name
Selecting the extention when copying a file name
How to copy the lister folder name?
Copy path to clipboard
Description Field
How to invoke the Copy-> Copy Filenames menu from shortcut
Right Click a file; Copy Path to Clipboard
Customized Print Files... button not working quite right
Copy file name as full path
Copynames right click
Copy path and filename
Get complete URL of a file?
Copy path to clipboard, escaped for Javascript, C++
Clipboard COPYNAMES doesn't work anymore with current folder
Stuck...copy link location/make 4 personal views
How to copy MD5 Checksum column?
Button to copy directory path of a folder?
List of files and folders from FIND window sending to Clipbo
Copy a file's path in a library
[Feature Request] Add a "Copy path to clipboard"
Including filname in the path displayed
How To Add 'Copy as Path' to Opus context menu?
Suggestion: "Copy filename" context menu command
Custom Context Menu commands: YOUR favorites?
Copy filenames separated by newlines?
How to install JScript describe in Copy Selected Filenames
List of FAQs organised by topic
Commands to copy selected filenames to the clipboard, with files & folder sizes
SetClip
Filename to Clip
MD5 or other file hash calculator
MD5 Checksum
Button to toggle and auto-size MD5 column
MD5 Checksum calculation for only selected files?
How can I create a path+file name list of selected files?