Launch command with (source/target OR selected files)

English support forum

Moderators: white, Hacker, petermad, Stefan2

jackhab
Junior Member
Junior Member
Posts: 35
Joined: 2008-03-05, 09:36 UTC

Launch command with (source/target OR selected files)

Post by *jackhab »

Is there a way to create one button which launches a command with either source and target paths when nothing is marked in the panels or marked paths when they were marked in the same panel.

Currently I use two two buttons: one with %X%P%N %T%M parameters, another with %C1 %C2 so that I can run Beyond Compare on either left/right panel or two files in the same panel.
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Launch command with (source/target OR selected files)

Post by *petermad »

Could you maybe give us the full Command and Parameter field for both buttons, to give a clearer idea of what you mean?
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
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Launch command with (source/target OR selected files)

Post by *Horst.Epp »

Beyond Compare can compare files or folders.
To use it I select 2 folders or 2 files bevor clicking the button with %C1 %C2
This works perfect but he wants to get the folders of both sites compared
while inside of them with no files selected.
This will not work because one of the parameters would be the current cursor position
in the active site.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
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
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Launch command with (source/target OR selected files)

Post by *Hacker »

petermad,
The idea as I understand it is to replicate the functionality of Compare by content (if selected, compare selected, if not, compare to the file with same name in the opposite panel).

jackhab,
You can use the Comparetool wincmd.ini key to define an external compare tool directly.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Launch command with (source/target OR selected files)

Post by *petermad »

This will not work because one of the parameters would be the current cursor position
in the active site.
Hmm, why not use %X%P %T - that should compare the parent folders. If the backslash in the end of the path is a problem, then TC 10 has a new feature, so you can cut off the backslash with %P:~0,-1
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.
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
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Launch command with (source/target OR selected files)

Post by *Horst.Epp »

petermad wrote: 2021-05-04, 14:57 UTC
This will not work because one of the parameters would be the current cursor position
in the active site.
Hmm, why not use %X%P %T - that should compare the parent folders. If the backslash in the end of the path is a problem, then TC 10 has a new feature, so you can cut off the backslash with %P:~0,-1
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.
The request is to compare 2 files or 2 folders with the same buttton
while inside of the folders to be compared for the folder case.
I don't see how that can be accomplished with simple manipulations of the parameters
because this constructs will fail if 2 files should be compared.
For me the whole request is almost useless.
If I want to compare folders %C1 %C2 work and the same button works for 2 files.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
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
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Launch command with (source/target OR selected files)

Post by *petermad »

using %COMSPEC% /C in the Command field It if possible to test if a file/dir is actively selected or not by testing if %Y%S1 has a value or not, hence conditionally execute one command or the other.

It is also possibley to test whether a file or a dis has been actively selected by testing if %P%S1\* exists.
But I am still not sure exacltly what jackhab wants - that is why I would like to see the content of his buttons.
Last edited by petermad on 2021-05-04, 16:31 UTC, edited 1 time in total.
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
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Launch command with (source/target OR selected files)

Post by *Horst.Epp »

petermad wrote: 2021-05-04, 16:25 UTC using %COMSPEC% /C in the Command field It if possible to test if a file/dir is actively selected or not by testing if %Y%S1 has a value or not, hence conditionally execute one command or the other - that is why I would like to see the content of jackhab's buttons.
He said
Currently I use two two buttons: one with %X%P%N %T%M parameters, another with %C1 %C2
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
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
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Launch command with (source/target OR selected files)

Post by *petermad »

Is there a way to create one button which launches a command with either source and target paths
That is the part that is ambiguous to me, because to me the source and target paths are %P and %T - but he uses %P%N and %T%M which are subdirs to the source and target path.

Does jackhab want the displayed folder in source and target panel compared, or does he want the directories under the cursor in the source and target panel compared???
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
jackhab
Junior Member
Junior Member
Posts: 35
Joined: 2008-03-05, 09:36 UTC

Re: Launch command with (source/target OR selected files)

Post by *jackhab »

@*Hacker
Defining custom compare tool does not solve it since it always requires two files/dirs to be marked

Currently, the two buttons I have are:
C:\my\Run\BeyondCompare\BCompare.exe %X%P%N %T%M
and
C:\my\Run\BeyondCompare\BCompare.exe %C1 %C2

I hope the attached pictures can explain what I'm trying to accomplish with one button.

Image: https://i.imgur.com/VwceaCt.png

Image: https://i.imgur.com/NKCcMJB.png
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Launch command with (source/target OR selected files)

Post by *Horst.Epp »

jackhab wrote: 2021-05-05, 08:19 UTC @*Hacker
Defining custom compare tool does not solve it since it always requires two files/dirs to be marked

Currently, the two buttons I have are:
C:\my\Run\BeyondCompare\BCompare.exe %X%P%N %T%M
and
C:\my\Run\BeyondCompare\BCompare.exe %C1 %C2

I hope the attached pictures can explain what I'm trying to accomplish with one button.

Image: https://i.imgur.com/VwceaCt.png

Image: https://i.imgur.com/NKCcMJB.png
I use Beyond Compare and I don't see your problem.
One button with %C1 %c2 does it all for me.
I can select 2 files or 2 folders and hit this button.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
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
jackhab
Junior Member
Junior Member
Posts: 35
Joined: 2008-03-05, 09:36 UTC

Re: Launch command with (source/target OR selected files)

Post by *jackhab »

2Horst.Epp
Do you mean you select them by pressing Insert button?
jackhab
Junior Member
Junior Member
Posts: 35
Joined: 2008-03-05, 09:36 UTC

Re: Launch command with (source/target OR selected files)

Post by *jackhab »

Well, thank you, guys, for the ideas. I've finally found how to solve it.

The button should be defined like this: wrapper.bat %P%S %T%M

This will pass both marked files and the file from the other panel. So in case I marked two files this will actually pass tree file names.

In wrapper.bat I pass only first two parameters: C:\my\Run\BeyondCompare\BCompare.exe %1 %2.

So now if I have two files marked in the current panel it will compare the marked files; if I don't have marked files it will compare files under cursor in the left and right panels.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Launch command with (source/target OR selected files)

Post by *Horst.Epp »

jackhab wrote: 2021-05-05, 08:46 UTC 2Horst.Epp
Do you mean you select them by pressing Insert button?
You can use the insert key or Ctrl-click on a file.
If you dont select any file the current files in left and right panel are used by %C1 and %C2
So I don't see any need for your Wrapper bat file as it works perfect without addional actions.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
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
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Launch command with (source/target OR selected files)

Post by *Horst.Epp »

jackhab wrote: 2021-05-05, 09:15 UTC Well, thank you, guys, for the ideas. I've finally found how to solve it.

The button should be defined like this: wrapper.bat %P%S %T%M

This will pass both marked files and the file from the other panel. So in case I marked two files this will actually pass tree file names.

In wrapper.bat I pass only first two parameters: C:\my\Run\BeyondCompare\BCompare.exe %1 %2.

So now if I have two files marked in the current panel it will compare the marked files; if I don't have marked files it will compare files under cursor in the left and right panels.
Thats all made this way by default without the need for any wrapper if you have one button with %C1 and %C2.
Its the same logic as the internal compare has.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
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
Post Reply