Solved

Combine multiple CSV's into 1 based on Date modified

Posted on 2014-09-09
2
243 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
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.
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now