Option for different slashes in Copy Full Pathnames

I program with RStudio daily and use Copy Full Pathnames regularly - it's a real time saver.
However, RStudio doesn't like the backslashes in the pathnames and requires them to be either:

  • escaped with another backslash (all \ become \\), or
  • converted to single forward slashes (all \ become /)

It would be useful to have an option for the Copy Full Pathnames command to do so using either \\ or /. I'd be happy with either option, but user-selectable between \, \\ and / them would be even better.

Does such an option exist? If so, where would I find it?
If not, can I offer as a feature request?

Thanks.

Edit -> Copy Other -> Copy Full Pathnames (Double Backslashes)

Thanks Jon, but I can't see that under Copy Other. Is it something I need to add in options?
Using v12.21

image
image

Your menus look like they date back to an older version. You could reset the toolbar to the newer factory defaults, but you probably wouldn't want to as it looks like you've customized other parts of it.

Here's the current Copy Other menu in XML format which you can paste on to your menu to get the newer options:

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" separate="yes" textcol="none" type="menu">
	<label>Copy O&amp;ther</label>
	<icon1>#copyfilenames</icon1>
	<button backcol="none" display="label" label_pos="right" textcol="none">
		<label>Short Names Only</label>
		<tip>Copies the short (8.3) filenames of all selected files to the clipboard</tip>
		<function type="normal">
			<instruction>Clipboard COPYNAMES=short,nopaths,single</instruction>
		</function>
	</button>
	<button backcol="none" display="label" label_pos="right" textcol="none">
		<label>Short Pathnames</label>
		<tip>Copies the short (8.3) pathnames of all selected files to the clipboard</tip>
		<function type="normal">
			<instruction>Clipboard COPYNAMES=short</instruction>
		</function>
	</button>
	<button backcol="none" display="label" label_pos="right" textcol="none">
		<label>URLs</label>
		<tip>Copies the locations of all selected files to the clipboard as URLs</tip>
		<function type="normal">
			<instruction>Clipboard COPYNAMES=url</instruction>
		</function>
	</button>
	<button backcol="none" display="label" label_pos="right" textcol="none">
		<label>MD5 Checksums</label>
		<tip>Copies the MD5 checksums of all selected files to the clipboard</tip>
		<function type="normal">
			<instruction>Clipboard COPYNAMES=hash</instruction>
		</function>
	</button>
	<button backcol="none" display="label" label_pos="right" textcol="none">
		<label>MD5 Checksums (Alternate)</label>
		<tip>Copies the MD5 checksums of all selected files to the clipboard (alternate format)</tip>
		<function type="normal">
			<instruction>Clipboard COPYNAMES=hash2</instruction>
		</function>
	</button>
	<button backcol="none" display="label" label_pos="right" textcol="none">
		<label>SHA-1 Checksums</label>
		<tip>Copies the SHA-1 checksums of all selected files to the clipboard</tip>
		<function type="normal">
			<instruction>Clipboard COPYNAMES=hash4</instruction>
		</function>
	</button>
	<button backcol="none" display="label" label_pos="right" textcol="none">
		<label>SHA-1 Checksums (Alternate)</label>
		<tip>Copies the SHA-1 checksums of all selected files to the clipboard (alternate format)</tip>
		<function type="normal">
			<instruction>Clipboard COPYNAMES=hash5</instruction>
		</function>
	</button>
	<button backcol="none" display="label" label_pos="right" separate="yes" textcol="none">
		<label>Copy Full Pathnames (Double Backslashes)</label>
		<tip>Copy full paths, and turn \\ into \\\\ for easy pasting into various programming languages</tip>
		<function type="normal">
			<instruction>Clipboard COPYNAMES=unc REGEXP (.*)\\(.*)# \1|\2 (.*)[|](.*)# \1\\\\\2</instruction>
		</function>
	</button>
	<button backcol="none" display="label" label_pos="right" separate="yes" textcol="none">
		<label>Folder Path</label>
		<tip>Copies the path of the current folder to the clipboard</tip>
		<function type="normal">
			<instruction>@nofilenamequoting</instruction>
			<instruction>Clipboard SET {sourcepath$|noterm}</instruction>
		</function>
	</button>
	<button backcol="none" display="label" label_pos="right" textcol="none">
		<label>Complete Folder Listing</label>
		<tip>Copies a complete listing of the current folder to the clipboard</tip>
		<function type="normal">
			<instruction>Print FOLDER AS=txt TO=clip FLATVIEW=no QUIET</instruction>
		</function>
	</button>
</button>

Just put that into the clipboard, then go into Customize mode (Settings > Customize Toolbars) and right-click in the menu where you want it, then select Paste.

Thanks Leo, that's done the trick. I was even able to add my own command for a forward slash separator as well.

For anyone who has the same question:

Clipboard COPYNAMES=unc REGEXP (.*)\\(.*)# \1/\2

A couple of follow-ups:

  1. When working out how the REGEXP command worked, I gathered that the double backslash command is actually doing two renames:
    a. (.*)\\(.*)# to \1|\2 (backslash to |)
    b. (.*)[|](.*)# to \1\\\\\2 (| to double backslash)
    Why does it need to be done like this?

  2. I may have missed out on other useful commands with upgrades due to my custom menus. Is a full list of the current default menus (and XML) available?

Thanks for the really quick response.

(I've fixed up your post, but have a look at Formatting tips specific to the Opus forum for how to use code blocks around regex to prevent the forum mangling the codes. Also useful for paths containing backslashes, and so on.)

  1. The # on the end of each regex is an Opus-specific extension which means they are applied repeatedly until the string stops changing.

    Both regex only modify one backslash or pipe character at a time, before being run again.

    If there was just one regex to turn \ into \\ then it would keep adding another backslash after the very first (or last) one in the string, never finish, and never get to any of the other backslashes.

    (Opus will eventually stop the loop if it goes on too long or the string gets too long, to prevent a situation like that taking forever or crashing the program. But the result still wouldn't be what you wanted.)

  2. The easiest way to get that is to reset your toolbars to the factory defaults and then compare them to your old toolbars. You can then drag anything you want from the default toolbars to your personal ones.

    Rename your personal toolbars first, of course! Don't reset them in-place or you'll lose your edits.

    If you then use your renamed versions as your main toolbars, it's then easy to flip on the default toolbars, and reset them if needed, to compare them again later on. This is what I do. I never use the actual default toolbars, except to check what's on them.

    Settings > Toolbars > Set as Default Toolbar Set can be used to make your current toolbars the ones that windows will use by default (unless they override it). You can also save toolbar sets from the same menu.

Thanks again Leo, superb support from you guys as usual.

1 Like