@ECHO OFF
IF [%1]==[] (SET CF=Curent folder) ELSE (SET Criteria=%1)
SET /A files_counter=0
SET ResultsFile=!files_in_folder.txt
DIR /b "%Criteria%" | find /v "%ResultsFile%" >%ResultsFile%
FOR /f "tokens=*" %%M in (%ResultsFile%) do CALL :COUNT
ECHO Total files: %files_counter%
ECHO Criteria: %Criteria%%CF%
ECHO Results saved in: %ResultsFile%
ECHO.
ECHO.
ECHO Usage:
ECHO.
ECHO CountF.bat [criteria]
ECHO.
ECHO criteria Path to folder that script should calculate files in.
ECHO Or any other filter like "*.txt". In this case script
ECHO will count only files with .txt extention.
ECHO Without parameter, current working folder will be
ECHO calculated with all files.
ECHO.
PAUSE
:COUNT
SET /A files_counter=%files_counter%+1
EXIT /B