title: Set Directory listing as variable in batch file dir /B /A-D /S | find /c /v "~~~"
body: <p>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:</p>
  
  <pre><code>set /a FILECOUNT=dir c:\Dir1 /B /A-D /S | find /c /v "~~~"
  echo %FILECOUNT%
  </code></pre>
  
  <p>The output of the dir is only a number, I can't figure out how to get that number into my variable. </p>