Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

English support forum

Moderators: petermad, Stefan2, white, Hacker

User avatar
xxxdo1
Junior Member
Junior Member
Posts: 80
Joined: 2024-11-03, 02:45 UTC

Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *xxxdo1 »

Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

For example, the path "\\\Secure FTP\User1\home\wwwroot\my001\"
remove \\\Secure FTP\User1, leaving only \home\wwwroot\my001\

How to do this using bat or script.
User avatar
beb
Power Member
Power Member
Posts: 554
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *beb »

PowerShell script .ps1

Code: Select all

$paths  = Get-Clipboard
$update = @()
foreach ($path in $paths) {
$update += $path.replace('\\\Secure FTP\User1','')
}
$update | Set-Clipboard
A usage example:
Image: https://i.imgur.com/G6JFrYZ.mp4
Note. I used "-replace '\\+','\'" for the example since I don't have "\\\Secure FTP\User1\..." paths in hand.

Edit.

To make a TotalComander button with the script:
User-command (usercmd.ini)

Code: Select all

[em_changeClipPaths]
cmd=pwsh -c "c:\Test\CopyFullNamesToClipChangePaths.ps1"
User-button:

Code: Select all

TOTALCMD#BAR#DATA
em_changeClipPaths

WCMICON2.DLL


0
-1
A usage example with the TC button (this time I used ".Replace('\\Network\','')" for it):
Image: https://i.imgur.com/sbdkIXg.mp4
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 80
Joined: 2024-11-03, 02:45 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *xxxdo1 »

2beb
This code does not achieve the desired effect. I want to copy the path of the selected object directly and automatically remove the unnecessary prefix path \\\Secure FTP\User1
Image: http://cdnjson.com/images/2025/02/04/Video_2025-02-04_031812.gif
User avatar
beb
Power Member
Power Member
Posts: 554
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *beb »

2xxxdo1
The PowerShell script does exactly and namely what you have requested it to do.
1. The cm_CopyFullNamesToClip command copies the fullname(s) of the file/folder under the cursor/selected files/folders into the clipboard.
2. The PowerShell script in its turn:
2.1. At first--automatically catches the clipboard contents and automatically changes the paths "\\\Secure FTP\User1" prefix to nothing.
2.2. Then--automatically replaces the initial clipboard contents with the modified one, now with the paths that do not include the "\\\Secure FTP\User1" prefix anymore.
3. Eventually, you get the clipboard contents with the automatically removed "\\\Secure FTP\User1" prefix, as requested.
That's it. Just take it (the clipboard contents with the modified path(s)) and do whatever you need to do with it.

I have modified Total Commander's user button to do the job in one click (via the cm_CopyFullNamesToClip,em_changeClipPaths chain command) as follows:

Code: Select all

TOTALCMD#BAR#DATA
cm_CopyFullNamesToClip,em_changeClipPaths

WCMICON2.DLL



-1
The script itself remains the same (see the code in my previous message above).
Here's how it works (now it's the real-life example, for which I installed the SFTP plugin and found a server for testing):
Image: https://i.imgur.com/Hmiyjrd.mp4
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10
Fla$her
Power Member
Power Member
Posts: 2835
Joined: 2020-01-18, 04:03 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *Fla$her »

2xxxdo1
Register the command in %COMMANDER_PATH%\Plugins\wdx\Autorun\autorun.cfg:

Code: Select all

LoadLibrary Plugins\Autorun_Runtime.dll

RegisterCommand 60000 CopyFullNamesWithoutFirst2PartsOfWFXPath

Func CopyFullNamesWithoutFirst2PartsOfWFXPath(lParam)
   SendMessage(AUTORUN_TCHANDLE, 1075, 2018)
   ClipGet List
   If StrLeft(List, 3) = '\\\' Then ClipPut(StrReplace(List, '\\\' & _
   StrPart(RequestCopyDataInfo('SP'), '\', 4) & '\' & StrPart(RequestCopyDataInfo('SP'), '\', 5), ''))
EndFunc
And use 60000 as an internal command. The description for cm_CommandBrowser can be added to Totalcmd.inc and Language\Wcmd_lng.inc.

If desired, it's possible to make a more universal version with a numerical parameter of the cut-off parts.
Overquoting is evil! 👎
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 80
Joined: 2024-11-03, 02:45 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *xxxdo1 »

2beb
It works, but using ps1 is too slow.
Is there any other more efficient method?


2Fla$her
I added this code to autorun.cfg and restarted TC, Use cmd=60000, popup message: Cannot find 60000
Image: http://cdnjson.com/images/2025/02/04/202524185251228.png
Fla$her
Power Member
Power Member
Posts: 2835
Joined: 2020-01-18, 04:03 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *Fla$her »

2xxxdo1
Is this the first use of the plugin? If so, see all stages of installation.
Overquoting is evil! 👎
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 80
Joined: 2024-11-03, 02:45 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *xxxdo1 »

2Fla$her
Thanks, it works, solved. Using the plug-in method is more efficient.

TC button, how to add an if condition.
For example, if it is a local path, use cm_CopyFullNamesToClip, if it is a network path, use command 60000
Fla$her
Power Member
Power Member
Posts: 2835
Joined: 2020-01-18, 04:03 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *Fla$her »

xxxdo1 wrote: 2025-02-04, 17:20 UTC if it is a local path, use cm_CopyFullNamesToClip, if it is a network path, use command 60000
This is not necessary in this case. It's enough to use only 60000 for both types of paths. It's more handy for one hotkey/button.

You're welcome. ;)
Overquoting is evil! 👎
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 80
Joined: 2024-11-03, 02:45 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *xxxdo1 »

2Fla$her
I use the autorun plugin to register command 60000. Every time I want to use it, I need to manually open cm_SrcUserDef and choose to load the template, otherwise TC cannot find command 60000.

How can I set it to load automatically when TC starts?
Fla$her
Power Member
Power Member
Posts: 2835
Joined: 2020-01-18, 04:03 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *Fla$her »

xxxdo1 wrote: 2025-02-05, 13:15 UTC Every time I want to use it, I need to manually open cm_SrcUserDef and choose to load the template, otherwise TC cannot find command 60000.
I didn't understand the meaning of this phrase. What could be the connection between the filtering window and copying paths to the clipboard?
Overquoting is evil! 👎
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 80
Joined: 2024-11-03, 02:45 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *xxxdo1 »

Fla$her wrote: 2025-02-05, 19:58 UTC I didn't understand the meaning of this phrase. What could be the connection between the filtering window and copying paths to the clipboard?
Demo example:
Image: https://s3.cdnjson.com/images/2025/02/07/Video_2025-02-07_172358.gif

The autorun plugin cannot be automatically loaded when TC starts. I need to open cm_SrcUserDef to load the autorun plugin manually, otherwise the command 80001 cannot be found.
Last edited by xxxdo1 on 2025-02-07, 09:28 UTC, edited 1 time in total.
User avatar
AntonyD
Power Member
Power Member
Posts: 1476
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *AntonyD »

2xxxdo1
Still, for completeness of understanding you could at least temporarily - but switch the interface to English?
It's not that hard - and it would make more sense to us.....

This of course doesn't answer your main current question (sorry for that) - but still defines a pleasant communication style...
#146217 personal license
Fla$her
Power Member
Power Member
Posts: 2835
Joined: 2020-01-18, 04:03 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *Fla$her »

2xxxdo1
Now I understand: you didn't cope with the installation. Make sure you have lines like these in wincmd.ini:

Code: Select all

[ContentPlugins]
0=%COMMANDER_PATH%\Plugins\wdx\Autorun\autorun.wdx

[Searches]
...
Autorun_SearchFlags=0|002002000020|||||||||0000|
Autorun_plugin=autorun.Autorun > 0
Overquoting is evil! 👎
User avatar
xxxdo1
Junior Member
Junior Member
Posts: 80
Joined: 2024-11-03, 02:45 UTC

Re: Using cm_CopyFullNamesToClip, can I remove the prefix path when copying a network path?

Post by *xxxdo1 »

2AntonyD
Sorry, I re-uploaded the English demo.
Image: https://s3.cdnjson.com/images/2025/02/07/Video_2025-02-07_172358.gif


2Fla$her
I should have completed the installation. My configuration is the same as yours.
But the autorun plugin cannot be automatically loaded when TC starts

Code: Select all

[ContentPlugins]
0=%COMMANDER_PATH%\Plugins\Wdx\Autorun\Autorun.wdx
0_detect=
0_date=1501801560
0_flags=0

[Searches]
AutoRun_ChangeClipPaths_SearchFor=
AutoRun_ChangeClipPaths_SearchIn=
AutoRun_ChangeClipPaths_SearchText=
AutoRun_ChangeClipPaths_SearchFlags=0|002002000020|||||||||0000|||
AutoRun_ChangeClipPaths_plugin=autorun.Autorun = 1
Post Reply