Combine multiple CSV's into 1 based on Date modified
Posted on 2014-09-09
I am trying to combine multiple csv files into one master csv file. by running a batch file from a Win 2003 server.
I have the following files all in the same directory-
FileA.csv -- date modified 9-6-2014 @ 4:17am
FileC.csv -- date modified 9-6-2014 @ 4:18am
FileB.csv -- date modified 9-7-2014 @ 4:19am
FileD.csv --date modified 9-7-2014 @ 4:20am
I want to combine all of these files into one csv using a bat like so:
copy *.csv MASTER.csv /Y /B
The problem seems to be that within the MASTER.csv it is seems to have listed the contents based on the name of the file. I open MASTER.csv and it reads top to bottom like:
data from FILEA
data from FILEB
data from FILEC
data from FILED
What I need to happen is to have the data written to MASTER,csv based on the date the file was modified. Like so:
data from FILEA.csv
data from FILEC.csv
data from FILEB.csv
data from FILED.csv
the above file names are for example only. In my real world scenario, I have no control over the file names.
Thanks for the Help!