When passing the parent path, an extra quote is added to the argument.

English support forum

Moderators: Hacker, petermad, Stefan2, white

Mapaler
Junior Member
Junior Member
Posts: 17
Joined: 2022-01-29, 06:05 UTC

When passing the parent path, an extra quote is added to the argument.

Post by *Mapaler »

When passing the parent path, an extra quote is added to the argument.

Set a button text.exe in the toolbar and the parameter is %P%S

Choose parent path (⇧..) and click the button.

The resulting path will be followed by an extra quotation mark.

Code: Select all

C:\Users\Mapaler\source\repos\SkyScan\Create User Folder\bin\Debug"
Image: https://imgur.la/image/1649-TotalCMD64-Total-Commander-%28x64%29-11.03-David-Attie.is63c

How to solve this problem?
User avatar
white
Power Member
Power Member
Posts: 5743
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: When passing the parent path, an extra quote is added to the argument.

Post by *white »

If you add a question mark, you can see what is passed to the program.

Code: Select all

?%P%S
No extra quote is added, but when a folder contains a space, the argument will be in between quotes.
I assume your program cannot handle this and shows the error shown in your screenshot. If so, you can include %Q.
Help wrote:%Q Turn off automatic quotation marks around certain parameters like %P%N when the name contains a space. The user will then have to place them by himself.
Mapaler
Junior Member
Junior Member
Posts: 17
Joined: 2022-01-29, 06:05 UTC

Re: When passing the parent path, an extra quote is added to the argument.

Post by *Mapaler »

This is indeed in line with the rules of Windows.
https://learn.microsoft.com/en-us/dotnet/api/system.environment.getcommandlineargs?view=net-9.0

This issue is caused by the Last Slash being passed to the path by Total Commander.

If I select a folder in the list, there will be no slash at the end of the path. However, if you select the parent path, there will be a slash at the end.
Image: https://imgur.la/image/Strip-2.isDM3
User avatar
white
Power Member
Power Member
Posts: 5743
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: When passing the parent path, an extra quote is added to the argument.

Post by *white »

Mapaler wrote: 2025-04-01, 13:21 UTC This issue is caused by the Last Slash being passed to the path by Total Commander.
And which program cannot handle that?
Fla$her
Power Member
Power Member
Posts: 2981
Joined: 2020-01-18, 04:03 UTC

Re: When passing the parent path, an extra quote is added to the argument.

Post by *Fla$her »

2Mapaler
I would have noticed that a long time ago. TC 11.03? Check on 11.51.
Overquoting is evil! 👎
Mapaler
Junior Member
Junior Member
Posts: 17
Joined: 2022-01-29, 06:05 UTC

Re: When passing the parent path, an extra quote is added to the argument.

Post by *Mapaler »

Fla$her wrote: 2025-04-01, 13:49 UTC 2Mapaler
I would have noticed that a long time ago. TC 11.03? Check on 11.51.
I've tested it and 11.51 still has this "bug".
white wrote: 2025-04-01, 13:45 UTC And which program cannot handle that?
Only WSH was able to get the final slash correctly, and all other languages I could use, were escaped as quotation marks.
I think any program that uses the CommandLineToArgv Win32API will have this problem, because that's the Windows parsing logic.
Fla$her
Power Member
Power Member
Posts: 2981
Joined: 2020-01-18, 04:03 UTC

Re: When passing the parent path, an extra quote is added to the argument.

Post by *Fla$her »

Mapaler wrote: 2025-04-02, 08:27 UTC I've tested it and 11.51 still has this "bug".
Hmm. Is there a difference between x32 and x64?
Overquoting is evil! 👎
Mapaler
Junior Member
Junior Member
Posts: 17
Joined: 2022-01-29, 06:05 UTC

Re: When passing the parent path, an extra quote is added to the argument.

Post by *Mapaler »

Fla$her wrote: 2025-04-02, 08:54 UTC Hmm. Is there a difference between x32 and x64?
This problem exists both x32 and x64.
Mapaler
Junior Member
Junior Member
Posts: 17
Joined: 2022-01-29, 06:05 UTC

Re: When passing the parent path, an extra quote is added to the argument.

Post by *Mapaler »

I asked the AI and it told me

When passing a path with spaces via a parameter, you should not include a slash at the end.

Code: Select all

YourProgram.exe "C:\path to folder"
If you do need to include a slash, you should escape with two slashes.

Code: Select all

YourProgram.exe "C:\path to folder\\"
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6950
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: When passing the parent path, an extra quote is added to the argument.

Post by *Horst.Epp »

2Mapaler
It doesn't make sense to tell us what AI says, there is no AI knowing the real world.
TC has no problem with slash or no slash with such parameters.
You were asked to tell us what program has problems with it ?
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
User avatar
AntonyD
Power Member
Power Member
Posts: 1554
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: When passing the parent path, an extra quote is added to the argument.

Post by *AntonyD »

https://ss64.com/nt/syntax-esc.html
Special Cases using backslash escape
To save a directory path with a trailing backslash (\) requires adding a second backslash to 'escape the escape'
so for example instead of "C:\My Docs\" use "C:\My Docs\\"
https://learn.microsoft.com/en-us/cpp/cpp/main-function-command-line-args?view=msvc-160#parsing-c-command-line-arguments
A double quote mark preceded by a backslash (") is interpreted as a literal double quote mark (").
https://users.rust-lang.org/t/interpret-the-path-enclosed-in-double-quotes-on-windows/38173/11
better read starting from "For example, the following is a quick summary of the behaviour on my Windows 10 box."

https://daviddeley.com/autohotkey/parameters/parameters.htm
Last edited by AntonyD on 2025-04-02, 11:43 UTC, edited 3 times in total.
#146217 personal license
Mapaler
Junior Member
Junior Member
Posts: 17
Joined: 2022-01-29, 06:05 UTC

Re: When passing the parent path, an extra quote is added to the argument.

Post by *Mapaler »

2Horst.Epp

I use %P%S to pass the selected folder and include the path in quotation marks when there are spaces.
  1. If you select a folder, there is no slash after the passed parameters;
  2. When the parent directory is selected, there is a slash after the passed parameters.
When case 2, the parameters captured within the software end in quotation marks, which leads to parsing errors for the file path.

Image: https://imgur.la/image/1668-CreateUserFolder-%E5%88%9B%E5%BB%BA%E7%94%A8%E6%88%B7%E6%96%87%E4%BB%B6%E5%A4%B9.iBs95
Fla$her
Power Member
Power Member
Posts: 2981
Joined: 2020-01-18, 04:03 UTC

Re: When passing the parent path, an extra quote is added to the argument.

Post by *Fla$her »

2Mapaler
That is, this is not the problem of the TC, but of the application to which the path with the backslash is passed.
Last edited by Fla$her on 2025-04-02, 12:02 UTC, edited 1 time in total.
Overquoting is evil! 👎
User avatar
white
Power Member
Power Member
Posts: 5743
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: When passing the parent path, an extra quote is added to the argument.

Post by *white »

Fla$her wrote: 2025-04-02, 08:54 UTC Hmm. Is there a difference between x32 and x64?
No, and it has been like this for a very long time.
Help wrote:%P causes the source path to be inserted into the command line, including a backslash (\) at the end.
When the parent entry ".." is selected, %S produces no result, leaving the path with a trailing backslash.
Mapaler wrote: 2025-04-01, 13:21 UTC This is indeed in line with the rules of Windows.
Mapaler wrote: 2025-04-02, 08:27 UTC I think any program that uses the CommandLineToArgv Win32API will have this problem, because that's the Windows parsing logic.
According to Windows rules, the way arguments are parsed is left entirely up to the program being launched. This makes it messy and inconsistent. Windows programs also don’t use a consistent way of parsing arguments. The CommandLineToArgvW API and similar functions in programming languages are just a possible way to implement basic argument parsing. They are not a Windows rule.

The parent entry in TC is handled in a special way. It sometimes means parent folder, and other times current folder. When %P is directly followed by %S, %N, or similar placeholders that turn out to be empty (when the parent entry is selected), it might be useful if TC would remove the trailing backslash from %P. Alternatively, it might be useful if TC would return the value ".." or "." for the %S, %N, or similar placeholders.
Fla$her
Power Member
Power Member
Posts: 2981
Joined: 2020-01-18, 04:03 UTC

Re: When passing the parent path, an extra quote is added to the argument.

Post by *Fla$her »

white wrote: 2025-04-02, 12:01 UTC No, and it has been like this for a very long time.
At first, the problem was described in such a way that the path was passed only with a closing quotation mark after the backslash. Now it has become clear that this is not the case.
Overquoting is evil! 👎
Post Reply