[DONE] %ES_RESULTS%
[DONE] %ES_RESULTS%
Suggestion to have ES.exe set an environment variable with the number of matches it found (*) when (successfully) done.
(like ES_RESULTS=5 )
This would come in handy for some script I wrote a couple of months ago, but I even can't remember why (I worked around it anyway). So no urgency at all.
(*) Debatable what %ES_MATCHES% should be when the number of results is limited by the -n parameter.
(like ES_RESULTS=5 )
This would come in handy for some script I wrote a couple of months ago, but I even can't remember why (I worked around it anyway). So no urgency at all.
(*) Debatable what %ES_MATCHES% should be when the number of results is limited by the -n parameter.
Last edited by NotNull on Wed Oct 23, 2019 4:24 pm, edited 1 time in total.
Re: %ES_RESULTS%
How do other command line programs do this?
Would an option to return just the number of results be useful, for example:
ES foo bar -get-result-count
would output
23
if you had 23 files or folders matching foo bar
Then you do
for /f "tokens=*" %%a in (
'ES foo bar -get-result-count'
) do (
set es_ES_RESULTS=%%a
)
which would store the result count in %ES_RESULTS%
https://stackoverflow.com/questions/6359820/how-to-set-commands-output-as-a-variable-in-a-batch-file
I could also add -get-folder-result-count / -get-file-result-count
Would using the returned error level be better? error level < 0 = error, otherwise the result count is returned.
Would an option to return just the number of results be useful, for example:
ES foo bar -get-result-count
would output
23
if you had 23 files or folders matching foo bar
Then you do
for /f "tokens=*" %%a in (
'ES foo bar -get-result-count'
) do (
set es_ES_RESULTS=%%a
)
which would store the result count in %ES_RESULTS%
https://stackoverflow.com/questions/6359820/how-to-set-commands-output-as-a-variable-in-a-batch-file
I could also add -get-folder-result-count / -get-file-result-count
Would using the returned error level be better? error level < 0 = error, otherwise the result count is returned.
Re: %ES_RESULTS%
I like that.Would using the returned error level be better? error level < 0 = error, otherwise the result count is returned.
My (silly) first thought was a dotted error level.
So something like 1.256, where 1 was the error level & 256 was the number of results returned.
Then you'd only need to parse the .256 part to get the number of results.
Re: %ES_RESULTS%
You are right; they can't!
CMD starts a child process ES.exe and ES can't change change the environment of it's parent.
It i possible with some CMD commands, but those turn out to be internal (= part of CMD.exe) and not external (.exe) as I assumed.
The error level used to be 8-bit (0..255), but maybe that has changed in modern Windows versions.Would using the returned error level be better?
But still: redefining those return codes will cause too much side effects.
For example conditional commands. || and && look for errorlevel 0 / not 0 : ES.exe test && echo success / ES.exe test || echo error
EDIT: Just tested: Large return codes and negative ones are allowed on Win10.
Yes. please!Would an option to return just the number of results be useful, for example:
ES foo bar -get-result-count
Checking can be shortened to: for /f %%a in ('ES.exe foo bar -get-result-count') do set ES_RESULTS=%%a
Re: %ES_RESULTS%
ES-1.1.0.12.zip
ES.exe foo bar -get-result-count
Output:
23
getresultcount.bat example:
for /f "tokens=*" %%a in ('es foo bar -get-result-count') do (set ES_RESULTS=%%a)
echo %ES_RESULTS%
Notes:
The total result count is returned.
-n <count> is ignored
ES sets -n to 0 when using -get-result-count
This makes -get-result-count very fast if you do not specify a search to get the total number of indexed files and folders, for example:
ES.exe -get-result-count
- Added -get-result-count command line option.
ES.exe foo bar -get-result-count
Output:
23
getresultcount.bat example:
for /f "tokens=*" %%a in ('es foo bar -get-result-count') do (set ES_RESULTS=%%a)
echo %ES_RESULTS%
Notes:
The total result count is returned.
-n <count> is ignored
ES sets -n to 0 when using -get-result-count
This makes -get-result-count very fast if you do not specify a search to get the total number of indexed files and folders, for example:
ES.exe -get-result-count
Re: %ES_RESULTS%
Downloaded ... tested ... perfect!
And it is indeed blazingly fast. Thank you!
-get-result-count (and also -date-format ) are not yet mentioned on the Command Line Interface support page, so I can only award you a 9.5 for your work
And it is indeed blazingly fast. Thank you!
-get-result-count (and also -date-format ) are not yet mentioned on the Command Line Interface support page, so I can only award you a 9.5 for your work
Re: %ES_RESULTS%
For the people using PowerShell:
or
Powershell will see any output as text (string). With these commands the $ES_RESULTS variable will be converted to a 32-bit integer.
(Now you only have to be careful not to pass the 4 billion files limit )
Code: Select all
.\ES.exe -getresultcount | % {$ES_RESULTS = $_ -as [int]}
Code: Select all
$ES_RESULTS = (.\ES.exe -getresultcount).Toint32($null)
(Now you only have to be careful not to pass the 4 billion files limit )
Re: %ES_RESULTS%
Added -get-result-count and -date-format to the support wiki, thanks.
https://www.voidtools.com/support/everything/command_line_interface/
https://www.voidtools.com/support/everything/command_line_interface/
Re: %ES_RESULTS%
There is something strange going on with -get-result-count.
If I add -sort date-run or -sort run-count as extra option to ES.exe, the result count is off.
Any idea what's going on?
Example:
TEST SCRIPT:
RESULT:
If I add -sort date-run or -sort run-count as extra option to ES.exe, the result count is off.
Any idea what's going on?
Example:
TEST SCRIPT:
Code: Select all
@setlocal
@echo off
set ES=C:\TOOLS\EVERYTHING\ES.EXE
set QUERY=/ad wfn:*system32*
rem set QUERY=/ad wfn:*everything*
"%ES%" %QUERY%
echo on
"%ES%" %QUERY% -sort name -getresultcount
"%ES%" %QUERY% -sort path -getresultcount
"%ES%" %QUERY% -sort size -getresultcount
"%ES%" %QUERY% -sort extension -getresultcount
"%ES%" %QUERY% -sort date-created -getresultcount
"%ES%" %QUERY% -sort date-modified -getresultcount
"%ES%" %QUERY% -sort date-accessed -getresultcount
"%ES%" %QUERY% -sort attributes -getresultcount
"%ES%" %QUERY% -sort file-list-file-name -getresultcount
"%ES%" %QUERY% -sort run-count -getresultcount
"%ES%" %QUERY% -sort date-recently-changed -getresultcount
"%ES%" %QUERY% -sort date-run -getresultcount
Code: Select all
C:\Program Files\WindowsApps\Microsoft.LanguageExperiencePacknl-nl_17134.4.6.0_neutral__8wekyb3d8bbwe\Windows\System32
C:\Windows\System32
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort name -getresultcount
2
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort path -getresultcount
2
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort size -getresultcount
2
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort extension -getresultcount
2
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort date-created -getresultcount
2
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort date-modified -getresultcount
2
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort date-accessed -getresultcount
2
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort attributes -getresultcount
2
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort file-list-file-name -getresultcount
2
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort run-count -getresultcount
1
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort date-recently-changed -getresultcount
2
C:\temp>"C:\TOOLS\EVERYTHING\ES.EXE" /ad -n 20 wfn:*system32* -sort date-run -getresultcount
1
Re: %ES_RESULTS%
Thanks for the bug report.
The issue occurs when sorting by a "Special sort"
Everything consider a sort "special" when sorted by Recent change, Run Count or Date run.
When sorting by a special sort, items with a special sort property (eg: Run Count) are excluded from the total item count returned from the IPC query.
I've fixed the issue for Everything 1.4.1.947.
This fix will return the correct number of items for special sorts.
The issue occurs when sorting by a "Special sort"
Everything consider a sort "special" when sorted by Recent change, Run Count or Date run.
When sorting by a special sort, items with a special sort property (eg: Run Count) are excluded from the total item count returned from the IPC query.
I've fixed the issue for Everything 1.4.1.947.
This fix will return the correct number of items for special sorts.
Re: %ES_RESULTS%
Thanks for explaining!
Briefly tested the new version 947 : all OK.
Thank you!
Briefly tested the new version 947 : all OK.
Thank you!