Rob van der Woude's Scripting Pages

Help text for Count.cs

(view help text of Count.cs as plain text)

Count.exe,  Version 1.00
Count specified objects and return result as errorlevel

Usage:    Count.exe  filespec  [ /S ]  [ /Q ]

   or:    some_prog  |  Count.exe  [ filter ]  [ /Q ]

Where:    filespec      specifies files to be counted (default: *.*)
          some_prog     program whose output is to be counted (all lines)
          filter        filter for some_prog (count lines containing filter)
          /Q            Quiet mode: no screen output
          /S            recursive (include Subdirectories)

Examples:
=========

Count number of *.exe files in C:\Windows\System32 and subdirectories:
Count.exe C:\Windows\System32\*.exe /S

Count number of subdirectories in C:\Windows\System32:
DIR /AD /B /S C:\Windows\System32 | Count.exe

Count number of environment variables:
SET | Count.exe "="

Notes:    Instead of Count.exe, one could use Windows' native FIND.EXE
          with its /C switch in a FOR /F loop, but Count.exe may make
          your batch code easier to read, by using SET Count=%ErrorLevel%
          Count.exe returns the number of (matching) lines, not the
          number of occurrences of the specified filter string.
          Count result is displayed on screen and returned as errorlevel;
          both are limited to 32-bit integer values.
          Return code ("ErrorLevel") equals count result, or -1 for
          (command line) errors.

Written by Rob van der Woude
https://www.robvanderwoude.com

page last uploaded: 2022-10-05; loaded in 0.0049 seconds