I have the command below to count all directories that that follow the pattern 20??????
:
\'dir /b \"20??????\" | find /c \"2\"\'
(dir /b "20??????" | find /c "2")>>x.txt
set /p variable=
That's all.
Of course, if you don't want the file, just do this afterwards:
del x.txt
EDIT -- How to make the filename unique:
@Mai: use this to create a uniqe file name:
set timestamp=%date:.=%%time::=%
set timestamp=%timestamp:,=%
set timestamp=%timestamp:/=%
set timestamp=%timestamp:-=%
set filename=file%timestamp%.tmp
Add more replacements if the date format of your system culture has other characters inside