Page 3 of 3

Posted: 30 Jul 2008 12:38
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

Posted: 30 Jul 2008 12:43
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;

Posted: 30 Jul 2008 14:54
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;)

Re: "Copy Path" regexp transformation?

Posted: 16 Apr 2021 18:10
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.

Re: "Copy Path" regexp transformation?

Posted: 27 May 2022 21:30
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;

Re: "Copy Path" regexp transformation?

Posted: 27 May 2022 21:36
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.)