Start command parameters %m %n issue with quotes

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

NibbleByte
Junior Member
Junior Member
Posts: 9
Joined: 2020-12-28, 15:22 UTC

Start command parameters %m %n issue with quotes

Post by *NibbleByte »

Hello,

I'm trying to integrate Beyond Compare 3 with Total Commander. I've added 3 custom commands in the "Change start menu" with hotkeys, similar to the ones mentioned in this post: https://superuser.com/a/246127
I'm trying to make them work under any conditions: FTP, inside zip, files and folders with spaces. But I've got a corner case which I believe it is a bug or really inconsistent behavior. Here is what I've got:

The command tries to call Beyond Compare for the selected file on the left pane vs the selected file on the right pane.

Code: Select all

Command: C:\Programs\Beyond Compare 3\BCompare.exe
Parameters: %Z "%X%p\"%X%n "%X%t\"%X%m
This is the setup / selection:

Code: Select all

Left pane: d:\Downloads\Foo\readme.txt
Right pane: d:\Downloads\Bar\Sample Tokyo Map.bld
This fails if I run the command with left pane active (i.e. it is source pane?).
The result command parameters are (using ? parameter):
"d:\Downloads\Foo\\"readme.txt "d:\Downloads\Bar\\"Sample Tokyo Map.bld
Note that the "Sample Tokyo Map.bld" is not in quotes, but it has spaces so it breaks the functionality.

The same succeeds if the right pane is active. This is the resulting parameters:
"d:\Downloads\Foo\\"readme.txt "d:\Downloads\Bar\\""Sample Tokyo Map.bld"
Note that the quotes are automatically added by Total Commander, not the pattern.

The help / documentation doesn't mention anything about this.

Total Commander version: 9.51 32-bit

PS: Can I just wish for % parameter that just gives the full path to the selected left / right / source / target file and wraps it properly in quotes if need and works for archives and ftp... cause I've had to do a lot of trial and error to get to that hacky pattern you see above?


Edit:
As mentioned below, this also doesn't work properly:

Code: Select all

Command Pattern:
%Z%X%P%N %Z%X%T%M 

Setup:
Left pane: d:\Downloads\foo.zip\readme.txt
Right pane: d:\Downloads\bar.zip\Bar\README.txt

Result with active active left pane:
d:\Downloads\foo.zip\readme.txt README.txt

Result with active right pane:
d:\Downloads\foo.zip\readme.txt d:\Downloads\bar.zip\Bar\README.txt
Last edited by NibbleByte on 2020-12-28, 18:26 UTC, edited 1 time in total.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6429
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Start command parameters %m %n issue with quotes

Post by *Horst.Epp »

I have defined Beyound Compare as external compare tool in wincmd.ini
CompareTool="C:\Tools\Beyond Compare 2\BC2.exe"

I defined a button with the command
cm_CompareFilesByContent


No parameters are needed in this case !
Windows 11 Home x64 Version 23H2 (OS Build 22631.3296)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
joe910
Junior Member
Junior Member
Posts: 34
Joined: 2009-02-23, 03:05 UTC
Location: Peoria, IL USA

Re: Start command parameters %m %n issue with quotes

Post by *joe910 »

I use a button and have no issues - works regardless of what side is active. I do not use FTP so that may require something different, but works with archives. I use one for comparing folders and one for comparing files. Here is a copy of those buttons:

For Folders
TOTALCMD#BAR#DATA
"%!Cmdr_Apps%\Beyond Compare 4\BCompare.exe"
%X"%Z%P" %X"%Z%T"
"%!Cmdr_Apps%\Beyond Compare 4\BCompare.exe"
Compare Folders
%!Cmdr_Apps%\Beyond Compare 4\
0
-1

For Files
TOTALCMD#BAR#DATA
"%!Cmdr_Apps%\Beyond Compare 4\BCompare.exe"
%Z%X%P%N %Z%X%T%M
%!Cmdr_Apps%\Beyond Compare 4\BCompare.exe,1
Compare Files
%!Cmdr_Apps%\Beyond Compare 4
0
-1
NibbleByte
Junior Member
Junior Member
Posts: 9
Joined: 2020-12-28, 15:22 UTC

Re: Start command parameters %m %n issue with quotes

Post by *NibbleByte »

joe910 wrote: 2020-12-28, 16:46 UTC For Files
TOTALCMD#BAR#DATA
"%!Cmdr_Apps%\Beyond Compare 4\BCompare.exe"
%Z%X%P%N %Z%X%T%M
I've tried what you suggested and it does fix that issue, but it fails on archives. Here is how:

Code: Select all

Setup:
Left pane: d:\Downloads\foo.zip\readme.txt
Right pane: d:\Downloads\bar.zip\Bar\README.txt

Result with active active left pane:
d:\Downloads\foo.zip\readme.txt README.txt

Result with active right pane:
d:\Downloads\foo.zip\readme.txt d:\Downloads\bar.zip\Bar\README.txt
The folder is completely skipped now. This is again very inconsistent behavior or a bug (which forced me into those hacks you see above). Can you try it yourself, maybe I got it wrong somehow.

I remember trying to use the CompareTool replacement method, but I wasn't satisfied with the result, can't tell why.

PS: Merry Christmas :wink:
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6429
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Start command parameters %m %n issue with quotes

Post by *Horst.Epp »

NibbleByte wrote: 2020-12-28, 17:04 UTC
joe910 wrote: 2020-12-28, 16:46 UTC For Files
TOTALCMD#BAR#DATA
"%!Cmdr_Apps%\Beyond Compare 4\BCompare.exe"
%Z%X%P%N %Z%X%T%M
I've tried what you suggested and it does fix that issue, but it fails on archives. Here is how:

Code: Select all

Setup:
Left pane: d:\Downloads\foo.zip\readme.txt
Right pane: d:\Downloads\bar.zip\Bar\README.txt

Result with active active left pane:
d:\Downloads\foo.zip\readme.txt README.txt

Result with active right pane:
d:\Downloads\foo.zip\readme.txt d:\Downloads\bar.zip\Bar\README.txt
The folder is completely skipped now. This is again very inconsistent behavior or a bug (which forced me into those hacks you see above). Can you try it yourself, maybe I got it wrong somehow.

I remember trying to use the CompareTool replacement method, but I wasn't satisfied with the result, can't tell why.

PS: Merry Christmas :wink:
The CompareTool replacement method handles your example without problems for me.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3296)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
NibbleByte
Junior Member
Junior Member
Posts: 9
Joined: 2020-12-28, 15:22 UTC

Re: Start command parameters %m %n issue with quotes

Post by *NibbleByte »

I think I didn't like it, because it couldn't compare folders. So I made a Beyond Compare command for folder and decided to compare files the same way to be consistent. I was mainly inspired by https://superuser.com/a/246127

Now that I tried it, yes it does compare folders, I just need to mark them, which is a bit annoying (same goes for files with different names). Also I want to specify /sync key for folder comparisons.

Before Beyond Compare I used the "Commands/Synchronize Dirs"... :)

In any case, the bug seems to be real...
joe910
Junior Member
Junior Member
Posts: 34
Joined: 2009-02-23, 03:05 UTC
Location: Peoria, IL USA

Re: Start command parameters %m %n issue with quotes

Post by *joe910 »

I have no issues with my buttons as defined. I just tested it to make sure. I can use an archive on either side or both sides without issue. I use Win10 v2004.
NibbleByte
Junior Member
Junior Member
Posts: 9
Joined: 2020-12-28, 15:22 UTC

Re: Start command parameters %m %n issue with quotes

Post by *NibbleByte »

Well this is odd.
I have the same parameters as yours and with this setup (of files) it doesn't work:
Image: https://i.imgur.com/jr5QZQC.png

And the result is:

Code: Select all

d:\Foo.zip\readme.txt readme.txt
Can you download the zip archives from here and try it one last time?
https://www.dropbox.com/s/ex1xq1ftoc6obi2/Foo.zip?dl=0
https://www.dropbox.com/s/9ibuvh1cxybgdvn/Bar.zip?dl=0

My exact total commander version is 9.51 32 bit (2020-03-25)
I use Windows 10 v1909
But I believe this bug exists for years, as I did this setup long time ago. I'm just reporting it now.
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3854
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Re: Start command parameters %m %n issue with quotes

Post by *sqa_wizard »

Yes indeed, I can reproduce the failure.

Button with parameter ?%X%Z"%P%N" %X%Z"%T%M"
Left panel active: "d:\Foo.zip\readme.txt" "readme.txt" => missing path of right panel file
Right panel active:"d:\Foo.zip\readme.txt" "d:\Bar.zip\Bar\readme.txt"

Seems to be a regression:
Release Total Commander 8.0 public beta 23 wrote:14.03.12 Fixed: Button with parameter %Z%p or %Z%m used within an archive returned path without archive name (32/64)
Tested with TC 8.0 32 bit release worked fine, TC 9.51 32 bit fails

Added: I tracked it down to TC 9.12 working fine while it fails starting with TC 9.20
#5767 Personal license
User avatar
petermad
Power Member
Power Member
Posts: 14700
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Start command parameters %m %n issue with quotes

Post by *petermad »

Just for the record - you only need to use %Z and %X (and %Y) once in the parameters line. %X can be cancelled with %x

That means:
%Z%X%P%N %T%M
equals:
%Z%X%P%N %Z%X%T%M
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
NibbleByte
Junior Member
Junior Member
Posts: 9
Joined: 2020-12-28, 15:22 UTC

Re: Start command parameters %m %n issue with quotes

Post by *NibbleByte »

Bonus question: I'd love to sync folders with Android phone.
Beyond Compare expects this format: mtp://HUAWEI CAN-L11/Internal storage/Pictures
While Total Commander reports it like this: \\Pictures\

Any ideas how to handle this? :) I suspect it is currently impossible.
andry81
Junior Member
Junior Member
Posts: 97
Joined: 2018-11-22, 19:17 UTC

Re: Start command parameters %m %n issue with quotes

Post by *andry81 »

NibbleByte wrote: 2021-01-02, 13:04 UTC Bonus question: I'd love to sync folders with Android phone.
Beyond Compare expects this format: mtp://HUAWEI CAN-L11/Internal storage/Pictures
While Total Commander reports it like this: \\Pictures\

Any ideas how to handle this? :) I suspect it is currently impossible.
May be that would be useful:
`Drive letter for MTP connection under Windows` : https://android.stackexchange.com/questions/22979/drive-letter-for-mtp-connection-under-windows
NibbleByte
Junior Member
Junior Member
Posts: 9
Joined: 2020-12-28, 15:22 UTC

Re: Start command parameters %m %n issue with quotes

Post by *NibbleByte »

Wish there was a solution without installing additional software on my PC or my Android phone, since Total Commander kind of supports this already (I can browse my phone, I just can't get the correct path for the command parameters).
From the mentioned suggestions, the closest I can get is "PTP Drive and MTPdrive by Cranking Pixels", but it's quite a long stretch for my needs and it is mentioned it is slow.

I can hard-code the "mtp://" part, but for some reason, the path returned as parameter is only the current folder: "\\Random\Photo-0025.jpg", not the full path: "\\HUAWEI CAN-L11/Internal storage/Pictures/Random/Photo-0025.jpg".
User avatar
petermad
Power Member
Power Member
Posts: 14700
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Start command parameters %m %n issue with quotes

Post by *petermad »

2NibbleByte
You can try this:
1. In TC go to \\Pictures\
2. Press Ctrl+D and add the current dir to the Diretctory hotlist
3. Press Ctrl+D again and choose "Configure"
4. Find the just added item and look in the "Command" field - it would show something like cd ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_04e8&pid_6860#rfcna052kje#{6ac27878-4a6fa-4155-ba85-f98f491d4f32}\SID-{10001,SECZ9519042CHOHB,116229386240}\{22F44B5F-28CE-7ACC-27A6-5173BC8FFC00}

Maybe you can use this path - at least for a while, but it most likely might not work for long, since the ID is dynamically assigned.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
NibbleByte
Junior Member
Junior Member
Posts: 9
Joined: 2020-12-28, 15:22 UTC

Re: Start command parameters %m %n issue with quotes

Post by *NibbleByte »

Beyond compare doesn't understand that path. :(
I just realized that I also have "Windows Media Audio 2" plugin, which produces this path "\\\MediaAudio2\USB1\Internal storage\Pictures\Random" which is nicer, but of course it doesn't work with Beyond Compare.

Off-topic: wow, that plugin is really good. Quick view works, while the default implementation doesn't.
Post Reply