Solved

Combine multiple CSV's into 1 based on Date modified

Posted on 2014-09-09
2
253 Views
Last Modified: 2014-09-09
Hey experts-

I am trying to combine multiple csv files into one master csv file. by running a batch file from a Win 2003 server.

example:
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!
0
Comment
Question by:621tech
2 Comments
 
LVL 14

Accepted Solution

by:
sentner earned 500 total points
ID: 40312604
You can do something like this:

del MASTER.csv
for /f "tokens=*" %i in ('dir /od /b "FILE?.csv"') do type "%i">>MASTER.csv

This is from command line.  If used in a batch file, you'd replace %i with %%i.
0
 

Author Closing Comment

by:621tech
ID: 40312657
That worked perfectly. Thanks for the help!!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question