"Copy Path" regexp transformation?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
ReviewPilot
Posts: 150
Joined: 27 Jul 2007 09:21
Location: Germany

Post by ReviewPilot »

Hi guys,

I have another issue with backslashes where this great option described here does not help (enough).

We have a Wiki in our company, where web- & system/Network-paths are written with Slashes, not Backslashes.
Often I have to copy & paste a path here and insert it there (or other way round).

Now, my hope is there is a button or (selfmade?) shortcut in Xy where I can switch the pathdisplay or path"copy" between forward/backward slashes. Atm, I always have to copy&paste and then rewrite every single slash..

One way would be to simply add a row in the "To Clipboard"RMB-Menu, where the copied path has backslashes converted to slashes.
Additionally, the pathdisplay on top (how was it called) could maybe alternatively support forward slashes, then I could easily insert the Paths from the Wiki


Anyone?
Greets, ReviewPilot

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Post by admin »

ReviewPilot wrote:Hi guys,

I have another issue with backslashes where this great option described here does not help (enough).

We have a Wiki in our company, where web- & system/Network-paths are written with Slashes, not Backslashes.
Often I have to copy & paste a path here and insert it there (or other way round).

Now, my hope is there is a button or (selfmade?) shortcut in Xy where I can switch the pathdisplay or path"copy" between forward/backward slashes. Atm, I always have to copy&paste and then rewrite every single slash..

Anyone?
Greets, ReviewPilot
Come on, I thought you know XY better! :wink: That's an easy job for a UDC "Run Script".

Code: Select all

// replace \ by / in current item, then copy to clipboard
  replace $p, <curitem>, "", "/";
  copytext $p;

ReviewPilot
Posts: 150
Joined: 27 Jul 2007 09:21
Location: Germany

Post by ReviewPilot »

admin wrote: Come on, I thought you know XY better! :wink: That's an easy job for a UDC "Run Script".

Code: Select all

// replace \ by / in current item, then copy to clipboard
  replace $p, <curitem>, "", "/";
  copytext $p;
I have to admit, I never fooled around with this nice feature..
Just haven't had the time
(sorry;)

Beringela
Posts: 3
Joined: 07 May 2013 10:53

Re: "Copy Path" regexp transformation?

Post by Beringela »

This thread comes very near the top of a google search for "xyplorer copy linux path" so I'm posting this reply in case it helps others.

My requirement was to be able to copy a Windows path from XYplorer and paste it into a WSL2 CLI as a Linux path. For example, the Windows path: "\\wsl$\Ubuntu\home\whoever\bashexpt" should become "~/bashexpt".

Solution was to create a UDC script. In xyplorer choose User -> Manage Commands -> Run Script -> New... and enter this script (the indentation is important). Allocate this to a keystroke, eg ALT+L.

$p = <curpath>;
$p = replace($p,"\\wsl$\Ubuntu", "");
$p = replace($p,"\home\whoever", "~");
$p = replace($p,"\", "/");
copytext $p;

Where "whoever" is your WSL2 username.

Phanabani
Posts: 1
Joined: 27 May 2022 20:44

Re: "Copy Path" regexp transformation?

Post by Phanabani »

Beringela wrote: 16 Apr 2021 18:10 This thread comes very near the top of a google search for "xyplorer copy linux path" ...
Thanks so much for this script! This is exactly what I needed.

A few notes for other future people who've never scripted before (like me) --
  • The first line in the script should not be indented, but the following lines should be indented by at least one space. The formatting in Beringela's post removed the spaces. I fixed it below!
  • Disable Scripting > Step Mode so a debugging window doesn't pop up every time you run the script.

Code: Select all

$p = <curpath>;
  $p = replace($p,"\\wsl$\Ubuntu", "");
  $p = replace($p,"\home\whoever", "~");
  $p = replace($p,"\", "/");
  copytext $p;

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: "Copy Path" regexp transformation?

Post by highend »

but the following lines should be indented by at least one space
It's not a should, it's a requirement :)

Of course this has exceptions (multiline-scripts with captions, functions, etc.)
One of my scripts helped you out? Please donate via Paypal

Post Reply