This is in continuation with the question here. Batch Script: Concatenating multiple files in multiple folders into one file
I have 20 files with name 'new.csv' in 20 folders in the same parent directory. I want to concatenate all of them into one file. So, I want to do it in two steps.
I am using XCOPY to copy each new.csv of each folder to new1, new2, new3 etc. in the parent folder. If I can do this, in my parent folder, I have 20 csvs, new1, new2..new20.csv.
Then, I can just do a
copy new*.csv final.csv. So, this is the code that I wrote to make the copies of each of these
new.csvfrom each folder in the parent folder.
setlocal EnableDelayedExpansion set /a i=0 FOR /D /R %%G in ("*") DO ( cd %%G set /a i=i+1 XCOPY new.csv ..\new%!i!%.csv )
The problem is in creating a new file. I want to create 20 files with names, new1.csv, new2.csv, new3.csv...new20.csv. The counter value is getting incremented, but I cannot append it to 'new'. Could you please help.