Commands to copy selected filenames to the clipboard

Frequently asked questions.
User avatar
Posts: 36498
Joined: 07 Nov 2004, 01:30
OS: Windows 10 64-bit
Opus: Directory Opus 12
Location: London, UK
  • 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:

    wc1323_dopus.png (75.23 KiB) Viewed 7267 times

  • Adding similar commands to right-click context menus:

    To add a Copy Names item to your right-click file context menus:

    1. In Opus, click Settings -> Filetypes...
    2. Double-click All Files & Folders, near the top of the list.
    3. Select the Context Menu tab.
    4. Click New
    5. 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.)

    6. 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.


    • Filename Only: CLIPBOARD COPYNAMES=nopaths

    • Short Paths: CLIPBOARD COPYNAMES=short


    • UNC (network drives): CLIPBOARD COPYNAMES=unc

    • 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 (Opus 9 and above):

    Directory Opus 9 lets you modify what gets placed in the clipboard using regular expressions. Below are some examples. (See RegExp basics: Removing characters from start/end of names in the Rename Scripting forum if you need help learning the basics of regular expressions.)

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

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

    • Copy paths escaped for C++: See separate example.

  • 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, the command is:

    Print FOLDER AS=txt TO=clip FLATVIEW=no QUIET

User avatar
Posts: 36498
Joined: 07 Nov 2004, 01:30
OS: Windows 10 64-bit
Opus: Directory Opus 12
Location: London, UK
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:

200dpi_wc8500_dopus.png (116.31 KiB) Viewed 2306 times


Code: Select all

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);
      // 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.


Return to “Directory Opus FAQs”