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
"Copy Path" regexp transformation?
-
- Site Admin
- Posts: 60595
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Come on, I thought you know XY better! That's an easy job for a UDC "Run Script".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
Code: Select all
// replace \ by / in current item, then copy to clipboard
replace $p, <curitem>, "", "/";
copytext $p;
FAQ | XY News RSS | XY Twitter
-
- Posts: 150
- Joined: 27 Jul 2007 09:21
- Location: Germany
I have to admit, I never fooled around with this nice feature..admin wrote: Come on, I thought you know XY better! 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;
Just haven't had the time
(sorry;)
Re: "Copy Path" regexp transformation?
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.
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?
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?
It's not a should, it's a requirementbut the following lines should be indented by at least one space
Of course this has exceptions (multiline-scripts with captions, functions, etc.)
One of my scripts helped you out? Please donate via Paypal