title: count folders and subfolders with batch file
body: <p>I am looking to create a batch file that when given a pathway, it will count all the folders and sub folders within it.  So far I am only able to gather the number of folders within the 1st level of the pathway.  I will then pipe it to a text file.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>for /f %%a in ('dir /b /ad %folder%^|find /c /v "" ') do set count=%%a
  echo %count% folder(s^)&gt;&gt; !output!
  </code></pre>
  
  <p>Am I close to getting what I want? What do I need to tweek?</p>
  
  <p>Thanks!</p>