I know this is a common question but I run into some bugs and hope for some help.
I want to merge over a 1000 csv files in multiple subfolders into one file. The Script is in the MainFolder
and should run through the subfolder e.g. 01_2015
to 05_2015
and merge the csv files into one file in the MainFolder
.
I've got the following folder structure:
-MainFolder
-01_2015
-02_2015
-03_2015
-04_2015
-05_2015
The script I'm using (got it from here ):
@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 >>"%SUMMARY_FILE%"
SET /A LINE_COUNT=!LINE_COUNT! + 1
)
)
EXIT /B 0
It is actually running through the over 1000 files. But the files don't get merged. What to do?