Start command parameters %m %n issue with quotes

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

Moderators: Hacker, Stefan2, white

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

Start command parameters %m %n issue with quotes

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

This fails if I run the command with left pane active (i.e. it is source pane?).
The result command parameters are (using ? parameter):
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:
Note that the quotes are automatically added by Total Commander, not the pattern.

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:

Result with active active left pane:

Result with active right pane:

Last edited by NibbleByte on 2020-12-28, 18:26 UTC, edited 1 time in total.
Horst.Epp
Power Member
Posts: 5004
Joined: 2003-02-06, 17:36 UTC
Location: Germany

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

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 21H2 (OS Build 22000.778)
TC 10.50RC4 x64 / x86
Everything 1.5.0.1315a (x64)
joe910
Junior Member
Posts: 18
Joined: 2009-02-23, 03:05 UTC
Location: Peoria, IL USA

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

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
Posts: 9
Joined: 2020-12-28, 15:22 UTC

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

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:

Result with active active left pane:

Result with active right pane:

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
Horst.Epp
Power Member
Posts: 5004
Joined: 2003-02-06, 17:36 UTC
Location: Germany

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

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:

Result with active active left pane:

Result with active right pane:

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
The CompareTool replacement method handles your example without problems for me.
Windows 11 Home x64 Version 21H2 (OS Build 22000.778)
TC 10.50RC4 x64 / x86
Everything 1.5.0.1315a (x64)
NibbleByte
Junior Member
Posts: 9
Joined: 2020-12-28, 15:22 UTC

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

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
Posts: 18
Joined: 2009-02-23, 03:05 UTC
Location: Peoria, IL USA

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

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
Posts: 9
Joined: 2020-12-28, 15:22 UTC

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

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.
sqa_wizard
Power Member
Posts: 3773
Joined: 2003-02-06, 11:41 UTC
Location: Germany

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

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

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
Power Member
Posts: 11523
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

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

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
Danish Total Commander Translator
TC 10.50b7 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (21H2) 64bit, 'Everything' 1.4.1.1015 (x64)
TC 3.40b2 on Android 6 & 12
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
NibbleByte
Junior Member
Posts: 9
Joined: 2020-12-28, 15:22 UTC

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

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
Posts: 70
Joined: 2018-11-22, 19:17 UTC

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

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
Posts: 9
Joined: 2020-12-28, 15:22 UTC

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

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".
Power Member
Posts: 11523
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

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

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.
Danish Total Commander Translator
TC 10.50b7 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (21H2) 64bit, 'Everything' 1.4.1.1015 (x64)
TC 3.40b2 on Android 6 & 12
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
NibbleByte
Junior Member
Posts: 9
Joined: 2020-12-28, 15:22 UTC

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

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.