windows - Counting files using a batch file -
i tried following code in .bat file count number of files in directory:
for /f %%a in ('dir /a-d /b /s | find /c /v ""') set filecount=%%a echo %filecount% pause
however, doesn't work , doesn't pause. instead flashes ": unexpected @ time". if write
dir /a-d /b /s | find /c /v "" pause
it works fine , displays number of files want save number variable. doing wrong?
you need escape pipe,
@echo off /f %%a in ('dir /a-d /b /s ^| find /c /v ""') set filecount=%%a echo %filecount% pause
Comments
Post a Comment