Solved

Combine multiple CSV's into 1 based on Date modified

Posted on 2014-09-09
2
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…

688 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