User command to pass two file names to external executable

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
foxtrix
Junior Member
Junior Member
Posts: 3
Joined: 2017-02-18, 14:44 UTC

User command to pass two file names to external executable

Post by *foxtrix »

Sorry if something similar has been asked before.

I'm trying to create a Total Commander user command that passes two selected files to an executable (in my case 'meld' application).

I want to be able to send two filenames together with their path, regardless of whether they are in source and/or target panel, but I just can't manage to do so.

So, for example, using these parameters:
P%S %T%R

if one of the files is in the source and one in the target panel, then it works fine.
But if the two selected files (in red) are only in the source panel, then Total Commander sends these two files AND the file that is under the cursor in the target panel (even though this last file is not selected).

Please, is there a way to do what I intend?

Thanks!
User avatar
Dalai
Power Member
Power Member
Posts: 9388
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

%P%S2 should do what you want (you may need to quote the whole thing if TC doesn't do so).

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
foxtrix
Junior Member
Junior Member
Posts: 3
Joined: 2017-02-18, 14:44 UTC

Post by *foxtrix »

But if the two files I have selected (and want to send to external program) are in different panels, i.e. one is in source panel and the other is in target panel, that won't work.

I'm looking for a way to send any selected files and their paths to the external program.
So, for example:
- if I have two files selected in source panel, it would send those.
- if I have one file selected in source panel and one selected in target panel, it would send both (with their respective paths).
User avatar
Dalai
Power Member
Power Member
Posts: 9388
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Since there is no differentiation between selection of files and the file under the cursor (in case nothing is selected) I don't think it's possible. You can either create two buttons - one button for selection in one panel and one button for selection on both panels - or use one button with %P%S2 to use the files in the source panel only.

Maybe someone has a better idea.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3864
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Post by *sqa_wizard »

... user command that passes two selected files to an executable (in my case 'meld' application).
For this special case there is no need of a user command.
"Meld" is a file compare tool.

Just add a line to your wincmd.ini (assumed the file is meld.exe)

Code: Select all

[Configuration]
CompareTool="Put\in\your\path\meld.exe"
Now this is your standard compare tool.

Note:
I added some shortcuts for this:

Code: Select all

[Shortcuts]
A+C=cm_CompareFilesByContent
AS+C=cm_IntCompareFilesByContent
With Alt-C compare with the external tool (meld in your case)
With Shift-Alt-C compare with TC internal compare
#5767 Personal license
foxtrix
Junior Member
Junior Member
Posts: 3
Joined: 2017-02-18, 14:44 UTC

Post by *foxtrix »

Thanks! I didn't know that you could change the compare tool and use an external one, and at the same time keep the option of using the internal compare tool.

This works great. Thanks again!
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

BTW, there is a way of creating buttonbar button that will accept the same files that internal comparer opens, there are some special parameters:
Help wrote:%C1 Like the first parameter of "Compare by content": First selected file, or file under cursor
%C2 Like the second parameter of "Compare by content": Second selected file, or first selected in target panel, or file with same name in target panel. Note: If the right panel is active and less than 2 files are selected, %C1 and %C2 will be reversed.
This allows creating multiple buttons/commands for different compare tools.
Post Reply