How to copy file path with forward slash?

English support forum

Moderators: petermad, Stefan2, white, Hacker

Post Reply
Laish
New Member
New Member
Posts: 1
Joined: 2019-05-30, 18:41 UTC

How to copy file path with forward slash?

Post by *Laish »

Hi,

I'm currently using an Hotkey to run the command cm_CopyFullNamesToClip.
In the clipboard the path is set with backslash (i.e c:\dev\file.txt).

I would like to have the path with forward slash (i.e. c:/dev/file.txt), Is there any settings that influence that?

I know i can write a script and put it in the shortcuts bar (something like this https://superuser.com/a/977847) but i want to use the keyboard shortcut to run it.

Does anybody have any idea how to achieve that?

Thank you!
User avatar
Stefan2
Power Member
Power Member
Posts: 4349
Joined: 2007-09-13, 22:20 UTC
Location: Deutschland

Re: How to copy file path with forward slash?

Post by *Stefan2 »

Hi and welcome Laish.

Instead of into the shortcuts bar (buttonbar) you can write with that commands and parameters a "user defined command" (usercmd.ini),
which you can assign a keyboard shortcut to. (Configuration > Options > Misc.)


To aid you whit your actual task you can try to use an Add-on instead of an own script:
https://totalcmd.net/plugring/list2clip.html

https://www.ghisler.ch/board/viewtopic.php?t=1853


Or just use PowerShell:
viewtopic.php?t=48019


The forum is full with tips and tricks, just search for that keywords....
visr
Junior Member
Junior Member
Posts: 2
Joined: 2026-02-13, 12:36 UTC

Re: How to copy file path with forward slash?

Post by *visr »

I had the same question, and did not see a relevant option in List2Clip, so quickly coded a tiny CLI app that does gives forward slashes, and always quotes paths as well. That way I can easily copy it into code without worrying about escape characters and such.

https://github.com/visr/copy-paths-to-clipboard
User avatar
beb
Power Member
Power Member
Posts: 633
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: How to copy file path with forward slash?

Post by *beb »

A simple TotalCommander/Windows-native (PowerShell-based) solution, no third-party tools required:

user-command:

Code: Select all

[em_toForwardSlash]
cmd=pwsh -c (Get-Clipboard).replace('\','/')|Set-Clipboard
Now, the cm_CopyFullNamesToClip,em_toForwardSlash commands' chain does the job.

Example toolbar button:

Code: Select all

TOTALCMD#BAR#DATA
cm_CopyFullNamesToClip,em_toForwardSlash

WCMICON2.DLL
Copy Names with Path to Clipboard /using forward slash path delimiters/

0
-1
Note:
To force enclosing each path in double quotes (as mentioned in the message above), put the user command as follows:

Code: Select all

[em_toForwardSlashQuoted]
cmd=pwsh -c (Get-Clipboard).replace('\','/').split([Environment]::NewLine)|foreach{'"""{0}"""' -f $_}|Set-Clipboard
Then, the button becomes as follows:

Code: Select all

TOTALCMD#BAR#DATA
cm_CopyFullNamesToClip,em_toForwardSlashQuoted

WCMICON2.DLL
Copy Names with Path to Clipboard /using forward slash path delimiters/ and "quoted"

0
-1
NB:

Code: Select all

'"""{0}"""'
The triple quotes are there to override the TotalCommander quotes' handling; in PowerShell itself,'"{0}"' would be enough.
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Windows 11/Android 16
visr
Junior Member
Junior Member
Posts: 2
Joined: 2026-02-13, 12:36 UTC

Re: How to copy file path with forward slash?

Post by *visr »

Thanks, that looks like a good alternative.
I'd probably add "pwsh -NoProfile", since, depending on the profile, it can add a lot of latency.
Even with that the latency to start PowerShell is quite a bit higher than running the Rust CLI:

Code: Select all

❯ hyperfine 'pwsh -c 1'
Benchmark 1: pwsh -c 1
  Time (mean ± σ):      3.871 s ±  0.810 s    [User: 2.977 s, System: 1.201 s]
  Range (min … max):    2.317 s …  4.387 s    10 runs

❯ hyperfine 'pwsh -NoProfile -c 1'
Benchmark 1: pwsh -NoProfile -c 1
  Time (mean ± σ):     331.8 ms ±  18.2 ms    [User: 256.2 ms, System: 157.8 ms]
  Range (min … max):   299.6 ms … 364.3 ms    10 runs

❯ hyperfine 'copy-paths-to-clipboard some_file'
Benchmark 1: copy-paths-to-clipboard some_file
  Time (mean ± σ):      46.9 ms ±   6.8 ms    [User: 11.6 ms, System: 12.5 ms]
  Range (min … max):    34.5 ms …  59.4 ms    41 runs
User avatar
beb
Power Member
Power Member
Posts: 633
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: How to copy file path with forward slash?

Post by *beb »

2visr
Thank you too.
At least we give a user an option to decide what approach is better for them.
It's always great to have a choice.
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Windows 11/Android 16
Fla$her
Power Member
Power Member
Posts: 3459
Joined: 2020-01-18, 04:03 UTC

Re: How to copy file path with forward slash?

Post by *Fla$her »

beb wrote: 2026-02-15, 23:16 UTC At least we give a user an option to decide what approach is better for them.
And I even know which one. 😁 However, everyone decides for themselves:
FR: Copy names with full path - with / instead of \
Namen mit kompletten Pfad kopieren mit Forward Slashes
unix path of sftp connection to clipboard
Kopiere Namen mit Pfad in Zwischenablage mit '\', '\\' oder '/'
etc.
Overquoting is evil! 👎
Post Reply