%P without backslash

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
wolf
Junior Member
Junior Member
Posts: 7
Joined: 2004-03-24, 20:58 UTC

%P without backslash

Post by *wolf »

When I call a program using the change button bar feature, I can pass %P as parameter. %P represents the path terminated by a "\". Is there clever solution for removing the backslash?

Currently I have two ideas for a workaround.
1. using ? and do manual editing.
2. writing a proxy program

wolf
wolf
Junior Member
Junior Member
Posts: 7
Joined: 2004-03-24, 20:58 UTC

Post by *wolf »

Correction: In contrast to the (german) docu, totalcommander uses a slash not a backslash.

But my problem remains unsolved ..

Can anybody give me hint how to start kdiff3.
When I use
"%P" "%T"
the slashes are disturbing.

wolf :)
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6951
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

User a shell script and remove the trailing char with the string functions of cmd, before you invoke kdiff3.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50390
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Try %P. with the dot after it. The dot means "current dir", and most programs will accept it.
Author of Total Commander
https://www.ghisler.com
wolf
Junior Member
Junior Member
Posts: 7
Joined: 2004-03-24, 20:58 UTC

Post by *wolf »

:oops:

That is the simple solution, I was looking for.

Thank you!! :D
igor3v
Junior Member
Junior Member
Posts: 11
Joined: 2024-08-13, 14:52 UTC

Re: %P without backslash

Post by *igor3v »

This thread is a bit old :mrgreen: , but I just ran into the same problem.
By combining cmd-substrings and delayed environment variable expansion, I was able to produce the following native (Windows 10) one-liner:

Command:

Code: Select all

cmd /V:ON /K
Parameters:

Code: Select all

"set "ZZZZ=%T" && echo "target=%T" && echo "target_fixed=!ZZZZ:~0,-1!" && echo "source=%P%S""
This demo button produces a cmd.exe window with the following text:

Code: Select all

"target=c:\Temp\2\"
"target_fixed=c:\Temp\2"
"source=c:\Temp\1"
A bit ugly, but it works.
User avatar
white
Power Member
Power Member
Posts: 5748
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: %P without backslash

Post by *white »

2igor3v
Help wrote:Note: All parameters now support substring fields in the form :~start,length, e.g. %N:~2,5 or %N:~-8,5 . To append a number directly after the length value, use another ~ character, e.g. %N:~2,5~2. Negative vaules are measured from the end of the string. Example: %P:~0,-1 cuts off the backslash from the path.
The Start value -0 is special: %N:~-0,20 copies the first 20 characters of the name without extension, %N:~-0,-20 the first 20 characters of the extension without the name.
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: %P without backslash

Post by *Fla$her »

Overquoting is evil! 👎
Post Reply