I have the command below to count all directories that that follow the pattern 20??????
:
'dir /b "20??????" | find /c "2"'
For example, if I have the following directories, the command would return 6:
20090901 20090902 20090903 20090904 20090905 20090906
How can I store the result of this command (6 in the forementioned example) in a variable?
By default when a command line execution is completed it should either return zero when execution succeeds or non-zero when execution fails. When a batch script returns a non-zero value after the execution fails, the non-zero value will indicate what is the error number.
/r - iterate through the folder and all subfolders, i.e. recursively. %%I - placeholder for a path/filename. The above command simply lists all files in the current folder and all subfolders. Follow this answer to receive notifications.
set cmd="dir /b "20??????" | find /c "2" " FOR /F "tokens=*" %%i IN (' %cmd% ') DO SET X=%%i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With