Feature request for the "Copy names" command

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

Post Reply
Xenakios
New Member
Posts: 5
Joined: 2010 Mar 03, 23:58

Feature request for the "Copy names" command

Post by Xenakios »

I am a programmer, so it would be useful if the "Copy names" (Alt+C) command would copy the file name to the clipboard transformed so that it is suitable for use inside C++/Python etc source code. That is, the \ characters would be changed to \\. This should of course be optional behavior.

I know of course using hardcoded filenames in code is bad practice, but it often is quite convenient to do that while prototyping or when doing tools just for myself... :)
Kilmatead
Platinum Member
Platinum Member
Posts: 4578
Joined: 2008 Sep 30, 06:52
Location: Dublin

Post by Kilmatead »

You might look into the free utility ClipboardFusion which allows you to add/change/replace/remove any given text inside the clipboard - this can be set to be done automatically upon capture (it works fine with x2's Alt-C, etc).

It is easily configured to replace '\' with '\\'.

And, as it's casually indifferent to humanity's ultimate purpose, it cares not whether what you change is "best practice" or not. :D  Of course, perhaps if we install enough utilities, AI emergence will become a reality, and then you might be critiqued upon form and faculty. :wink:
User avatar
snakebyte
Gold Member
Gold Member
Posts: 430
Joined: 2003 May 07, 07:14
Location: Seattle
Contact:

Post by snakebyte »

You can achieve this with autohotkey and X2 user commands

Create a blank txt file and paste following code in it

Code: Select all

param = %1%
StringReplace, NewStr, param, \, \\, All
clipboard = %NewStr%
Save this file as C:\Temp\CopyEscapedPath.ahk

Create a new user command as

Code: Select all

>"C:\Program Files (x86)\AutoHotkey\AutoHotkey.exe" "C:\Temp\CopyEscapedPath.ahk" "$P"
assign a hotkey for this user command or add it to your toolbar.

This will work for a single selected file. For multiple files you can easily modify the above script to accept $A instead of $P as parameter. Use a loop to iterate over all the selected files.
Help! I'm an AI running around in someone's universe simulator.
Xenakios
New Member
Posts: 5
Joined: 2010 Mar 03, 23:58

Post by Xenakios »

Yes, I am aware there are external applications that can help with this, but I'd rather keep my system as "clean" as possible. I would not need for example Autohotkey at the moment for anything else, so it would be a bit heavy additional thing to have running in the system just for a little thing like this. Meh, maybe I'll just write my own clipboard transformer app then...  :P
User avatar
snakebyte
Gold Member
Gold Member
Posts: 430
Joined: 2003 May 07, 07:14
Location: Seattle
Contact:

Post by snakebyte »

In that case you could compile your autohotkey script as standalone exe file and uninstall autohotkey.

If you do not want to go autohotkey route and you only want to use whats already installed on your machine then you can also rewrite the script I mentioned above using vbscript which comes preinstalled on all versions of Windows.

Nikos blogged about this here

Your request is very user specific, what if I wanted the paths seperator to be replaced with '/' instead of '\\' for my samba share on my Linux machine? I won't count on this feature to ever be implemented directly in X2.
Help! I'm an AI running around in someone's universe simulator.
Post Reply