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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -