How to check the number of files in the %S variable?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
PiotrMPPL
Junior Member
Junior Member
Posts: 46
Joined: 2018-10-26, 07:04 UTC

How to check the number of files in the %S variable?

Post by *PiotrMPPL »

Hi

How to check the number of files in the %S variable?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48154
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: How to check the number of files in the %S variable?

Post by *ghisler(Author) »

That depends on the called program. For example, you can use the shift command in batch files to shift through all passed parameters.
Author of Total Commander
https://www.ghisler.com
User avatar
nsp
Power Member
Power Member
Posts: 1819
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: How to check the number of files in the %S variable?

Post by *nsp »

PiotrMPPL wrote: 2024-05-08, 06:48 UTC Hi

How to check the number of files in the %S variable?
you can write a powershell script like args.ps1

Code: Select all

Write-Host "You passed $($args.Count) arguments:"
$args | Write-Host
Read-Host -Prompt "Press any key to continue"
and call it like

Code: Select all

TOTALCMD#BAR#DATA
pwsh %COMMANDER_PATH%\script\args.ps1
%S
@default.ps1
args
%COMMANDER_PATH%\script\

-1
Fla$her
Power Member
Power Member
Posts: 2352
Joined: 2020-01-18, 04:03 UTC

Re: How to check the number of files in the %S variable?

Post by *Fla$her »

%S has a limit on the length of the command line. This way you can get accurate data on the number of items:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Addons\TCFS2\TCFS2.exe /ef tcm(-1,1) "eval(settext_wait(`Marked items count: `msg(1074,msg(1074,1000)+1004),findwnd(Static,,findwnd(#32770))))"
%S:~,0
wciconex.dll,73
Number of marked items

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Addons\TCFS2\TCFS2.exe /ef varset(1,msg(1074,1000)) tcm(-1,1) "eval(settext_wait(`Selected items count: `msg(1074,varget(1)+1004)?msg(1074,varget(1)+1004):if(msg(1074,varget(1)+1008),
msg(1074,varget(1)+1006)?1:0,1),findwnd(Static,,findwnd(#32770))))"%S:~,0
wciconex.dll,217
Number of selected items
Overquoting is evil! 👎
Post Reply