Solved

Combine multiple CSV's into 1 based on Date modified

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix Script: Loop over all days of a month 17 106
Microsoft Office Customization Tool’s Outlook problem 12 89
User profile Size Report 3 84
server DNS address could not be found 22 251
I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
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…

856 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