title: Batch count all files but exclude those in a specific folder
body: <p>So I'm going to count files in a directory including all subfolders and get a output as a number of how many files it found within the directory. The problem is I want to exclude all the folders that has the name <code>error</code>. Those files within that folder I do not want to be counted.  </p>
  
  <p><strong><em>Simply...</em></strong></p>
  
  <pre><code>for /r "\\server\share\folderA" %%G in (*.*) do (
  set /A count=count + 1
  )    
  echo %count%
  </code></pre>
  
  <p>Under folderA there are plenty of subfolders that I'm counting, but also the "error" folders that I do not want to count. </p>
  
  <p><strong><em>So I'm trying the following...</em></strong></p>
  
  <p>Create a temp file called <code>exclude.txt</code> and type <code>error</code> to that file</p>
  
  <pre><code>if not exist "c:\temp" mkdir "c:\temp" 2&gt;nul
  if not exist c:\temp\exclude mkdir c:\temp\exclude 2&gt;nul
  echo error&gt; %excludefolder%\exclude.txt
  </code></pre>
  
  <p>Now I want to combine this somehow. Basically do something like this...</p>
  
  <pre><code>for /r "\\server\share\folderA" %%G in (*.*) EXCLUDE: c:\temp\exclude\exclude.txt do (
  set /A count=count + 1
  )    
  </code></pre>
  
  <p>But I'm aware this will not work and I'm not sure how to work it out. Does anyone know? Thanks! </p>