I am trying to write a bat file that counts all files in a directory and subdirectoires and sets a variable based on the output. Something like this:
set /a FILECOUNT=dir c:\Dir1 /B /A-D /S | find /c /v "~~~"
echo %FILECOUNT%
The output of the dir is only a number, I can't figure out how to get that number into my variable.
for /f %%a in ('dir c:\Dir1 /B /A-D /S | find /c /v "~~~"') do set FileCount=%%a