How to pass full paths of files selected in both panes as parameters

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
mmm
Member
Member
Posts: 120
Joined: 2020-08-10, 12:32 UTC

How to pass full paths of files selected in both panes as parameters

Post by *mmm »

Hello,
Try as I may I cannot figure out how to pass full paths of files selected in both panes as parameters to a command line *.bat file when each pane shows a different directory.

The %P%N %T%M suggested in one of the older threads does not seem to work for different directories, but I may be wrong.

May I ask for a hint?

Many thanks,
mmm
User avatar
Stefan2
Power Member
Power Member
Posts: 4174
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: How to pass full paths of files selected in both panes as parameters

Post by *Stefan2 »

Hi and welcome.

- right click any button and chose "Modify..."
- in button click [Help]
- read at %C1

But %P%N %T%M should also work

Code: Select all

TOTALCMD#BAR#DATA
cmd /k
echo HALLO %C1 %C2 &ECHO %P%N %T%M
C:\WINDOWS\system32\cmd.exe
TEST echo %C1 %C2


-1
(TC-Button code, copy to clipboard and paste on TC buttonbar.


Please note that TC may or may not add quotes "..." dependent if white space are found in path or not.
In your batch you may get access to both argument content via %~1 %~2 parameters, instead of simple %1 %2 and handle proper quotes yourself.




If you have more problems, just post the content of your button here (right click and "Copy")



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

Re: How to pass full paths of files selected in both panes as parameters

Post by *Dalai »

%P%N %T%M is exactly the way to go. Please provide an example of how your button (or TC start menu item) looks. It might also be a good idea to post the parameter parsing part of your batch file because there are several pitfalls regarding quoting and even character sets.

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
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: How to pass full paths of files selected in both panes as parameters

Post by *MVV »

If one uses %P%N and %T%M, he shouldn't forget about proper quoting:

Code: Select all

Command: cmd.exe
Parameters: /c echo Source: %P%N & echo Target: "%T%M" & pause
User avatar
petermad
Power Member
Power Member
Posts: 14857
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: How to pass full paths of files selected in both panes as parameters

Post by *petermad »

2MVV
If one uses %P%N and %T%M, he shouldn't forget about proper quoting:
%P%N and %T%M does NOT need quoting, but %P%0.%E does need quoting ("%P%0.%E").

%P alone and %T alone does need quoting ("%P" and "%T").

%N does NOT need quoting, but %M does ("%M") (not consistant!!)

%P%S, %C1 and %C2 does NOT need quoting either.

%Pmy file.ext needs quoting ("%Pmy file.ext")
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.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
mmm
Member
Member
Posts: 120
Joined: 2020-08-10, 12:32 UTC

Re: How to pass full paths of files selected in both panes as parameters

Post by *mmm »

Does %P%N %T%M work for you when multiple files and/or directories is selected in each pane?
I succeeded in getting only one out of several items for each pane.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: How to pass full paths of files selected in both panes as parameters

Post by *MVV »

petermad,
You're right, %T%M really gets auto-quoted too, so neither of them should be quoted when passed as a parameter.

mmm,
Test it yourself, %P%N and %T%M ignore selection and always return focused files. If you need to get more than one selected file, you can try %R and %S for inserting multiple names into command line, but remember that total length of command line is limited. For huge selections %WL is much better though it only lists files in active panel.
mmm
Member
Member
Posts: 120
Joined: 2020-08-10, 12:32 UTC

Re: How to pass full paths of files selected in both panes as parameters

Post by *mmm »

petermad,
%R and %S looks good for the moment. Will test it thoroughly later.
Thanks for your immediate reply.
Best,
mmm
User avatar
petermad
Power Member
Power Member
Posts: 14857
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: How to pass full paths of files selected in both panes as parameters

Post by *petermad »

2mmm

If it is lists of all selected files/folders you want then use %P%S %T%R - or just %S %R if you don't need full path.
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.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
mmm
Member
Member
Posts: 120
Joined: 2020-08-10, 12:32 UTC

Re: How to pass full paths of files selected in both panes as parameters

Post by *mmm »

Petermad,
%P%S %T%R looks good for me; yet I am a tad confused about selection concept versus focus in TC.

For the nomenclature:
I use the term "selection" for files/directories highlighted in red color /usually by means of hitting space key on a focused item/.
I use the term "focus" for files/directories users clicked on last /greyish background in active window, no visible attribute in the other window/.

Now, I suspect that %P%S %T%R mixes up these two attributes as it returns a single file/directory with focus from both panes when no selection made. Am I correct?

If yes, is there a way to get selected items only and null when no selection made?

I do not want to be picky, just trying to sort out apples from oranges.

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

Re: How to pass full paths of files selected in both panes as parameters

Post by *Dalai »

2mmm
You might want to take a look at TC's help file - pressing F1 while editing a button opens the section about these parameters.

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

Re: How to pass full paths of files selected in both panes as parameters

Post by *petermad »

2mmm
If yes, is there a way to get selected items only and null when no selection made?
Yes - use %Y %P%S %T%R

_____________________

I use the term "focus" for files/directories users clicked on last /greyish background in active window, no visible attribute in the other window/.
You can use the InactiveFocus=1 parameter in the [Configuration] section of your winc,d.ini file to have the focused file in the inactive panel made visible.

Help wrote:InactiveFocus=0 Set to 1 or RGB value (see description of BackColor below) to show cursor in the target panel too. Accepts hex in form $BBGGRR.
Add $1000000 = dashes, $2000000=dashes/dots, $3000000=solid frame
I,myself use InactiveFocus=$FF0000
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.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
mmm
Member
Member
Posts: 120
Joined: 2020-08-10, 12:32 UTC

Re: How to pass full paths of files selected in both panes as parameters

Post by *mmm »

Petermad,
I believe I got what I asked for.
End of story.
I consider this Service Request closed.


I want you to know that I find your feedback absolutely stunning.
Thanks a lot for extraordinary support.

Best,
mmm
Post Reply