title: How to Merge multiple CSV files from different subfolders?
body: <p>I know this is a common question but I run into some bugs and hope for some help.</p>
  
  <p>I want to merge over a 1000 csv files in multiple subfolders into one file. The Script is in the <code>MainFolder</code> and should run through the subfolder e.g. <code>01_2015</code> to <code>05_2015</code> and merge the csv files into one file in the <code>MainFolder</code>.</p>
  
  <p>I've got the following folder structure:</p>
  
  <pre><code>-MainFolder
      -01_2015
      -02_2015
      -03_2015
      -04_2015
      -05_2015
  </code></pre>
  
  <p>The script I'm using (got it from <a href="https://stackoverflow.com/questions/32995274/how-to-merge-multiple-csv-files-which-are-under-different-subfolders-into-a-sing">here</a> ):</p>
  
  <pre><code>@ECHO OFF
  SETLOCAL ENABLEDELAYEDEXPANSION
  
  SET SUMMARY_FILE=sumfile.csv
  IF EXIST "%SUMMARY_FILE%" (DEL "%SUMMARY_FILE%")
  
  
  SET /A LINE_COUNT=1
  
  FOR /F "usebackq tokens=*" %%f IN (`DIR /S /B *.csv`) DO (
      FOR /F "usebackq tokens=*" %%s IN ("%%~f") DO (
          ECHO !LINE_COUNT!,%%s &gt;&gt;"%SUMMARY_FILE%"
          SET /A LINE_COUNT=!LINE_COUNT! + 1
      )
  )
  EXIT /B 0
  </code></pre>
  
  <p>It is actually running through the over 1000 files. But the files don't get merged. What to do?</p>