title: Batch for scanning dirs needs a possibility to skip defined dirs
body: <p>I have a batch which scans a directory structure and gives out the size of directorys I defined he should look for.</p>
  
  <p>E.g. the directory '10XXX' contains the subdirectorys '10001', '10002' and '10003'. Now lets say that the batch should look for the dir 'XYZ' in those subdirs. Result is a .csv with informations like '10001\XYZ' 100 Bytes; '10002\XYZ' 2000 Bytes; '10003\XYZ' 0 Bytes.</p>
  
  <p>The problem is the batch scans every directory every time it runs, which takes a lot of time and resources.</p>
  
  <p>My idea is to implement a section into the code that everytime the batch starts scanning a dir it takes a look into a .txt (for example) and when the dir name is found in that file the batch skips the dir.
  This is maybe not the most effective solution, but it will take less time and resources than scanning every dir every time.
  So different ideas are of course welcome.</p>
  
  <p>Unfortunately I have not enough knowledge to do it myself so I hope that someone could help me.</p>
  
  <p>Code:</p>
  
  <pre><code>@echo off &amp;setlocal 
  set /p rootfolder=&lt;Enter_Directory_Path_Here.txt 
  set /p savefolder=&lt;Enter_Save_Directory_Here.txt
  set "batpath=%~dp0" 
  
  pushd "%rootfolder%" 
  for /d %%i in (*) do (
  set "foldername=%%~nxi" 
  set "folder=%%i" 
  &gt;"%batpath%%%~nxi.csv" type nul 
  for /f "delims=" %%j in ('dir /ad /b "%%i\*"') do ( 
  set "subfolder=%%j" 
  call :procfolder 
  ) 
  &gt;"%batpath%%%~nxi.~csv" type nul 
  for /f "usebackq tokens=1* delims==" %%j in ("%savefolder%\patterns.txt") do ( 
  &gt;&gt;"%batpath%%%~nxi.~csv" findstr /b %%k "%batpath%%%~nxi.csv" 
  if errorlevel 1 &gt;&gt;"%batpath%%%~nxi.~csv" echo "%%j";"not found" 
  ) 
  &gt;nul move /y "%batpath%%%~nxi.~csv" "%batpath%%%~nxi.csv" 
  ) 
  popd 
  call :cleaner
  exit /b 
  
  :procfolder 
  setlocal 
  for /f "tokens=3" %%i in ('dir /a /-c "%folder%\%subfolder%\"^|findstr /c:"Datei(en)"') do &gt;&gt;"%batpath%%foldername%.csv" echo "%subfolder%";%%i;"Bytes"
  for /f "delims=" %%i in ('dir /ad /b "%folder%\%subfolder%\"') do ( 
  set "subfolder=%subfolder%\%%i" 
  call :procfolder 
  ) 
  endlocal 
  exit /b  
  </code></pre>