title: Batch file to count files in a in subdirectories
body: <p>I would like to get this batch file to count the files in the subdirectories and display the total files and directories. However, I'm not familiar with the syntax.</p>
  
  <pre><code>@ECHO OFF
  SET "rootpath=C:\Users\RX\Documents\01.00 Meters\100\EMC\EMC 15Aug2016 Level4\res"
  SET tcnt=0
  FOR /D %%D IN ("%rootpath%\*") DO (
    SET cnt=0
    FOR /F %%K IN ('DIR /A-D /S "%%D" 2^&gt;NUL ^| FIND "File(s)" ^|^| ECHO 0') DO (
      SET /A cnt+=%%K
    )
    SETLOCAL EnableDelayedExpansion
    ECHO %%D: !cnt!
    tcnt+=%%cnt
    ENDLOCAL
  )
  ECHO !tcnt!
  cmd /k
  </code></pre>