Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: I need help with a batch file that merges excel files into one


02 Jan 2014   #1

Windows 7 Ultimate 32bit
 
 
I need help with a batch file that merges excel files into one

This is what I want to achieve: I want to merge all excel files in a directory into one .csv file. The files in the directory are only *.xls, *.xlsx, and *.csv . I use a simple batch file that I put in the directory which has the following script:

Code:
echo off
copy /a *.* merged.csv
pause
And it works just fine but it merges the files alphabetically, which is not convenient for me. I want them to be merged in the order of their Date of creation or by Date modified. I've read this but I can't seem to make the script work for me. Please help me. Thank you very much in advance.

My System SpecsSystem Spec
.

03 Jan 2014   #2

Windows 7 ultimate x64
 
 

Hi, Welcome to Seven forums.

Try this.

for /f "tokens=*" %i in ('dir /b /o:d /A:-D "C:\YourDir\" ') do type "C:\YourDir\%i">> merged.csv & echo.>> merged.csv
My System SpecsSystem Spec
03 Jan 2014   #3

Windows 7 Ultimate 32bit
 
 

Thanks for the reply but it doesn't work The cmd window flashes for a quick while but nothing anymore happens
My System SpecsSystem Spec
.


12 Jan 2014   #4

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

Quote   Quote: Originally Posted by nikoloff View Post
Thanks for the reply but it doesn't work The cmd window flashes for a quick while but nothing anymore happens
You have to open cmd prompt first then do the command. But the command is wrong! It simply concatenates the files. It doesn't convert to csv.
My System SpecsSystem Spec
Reply

 I need help with a batch file that merges excel files into one




Thread Tools



Similar help and support threads for2: I need help with a batch file that merges excel files into one
Thread Forum
Batch file to copy files from C drive to USB Backup and Restore
Solved Batch File that grabs file names from folder to insert into batch file General Discussion
Solved Batch File to Move a list of files. General Discussion
How to create a batch file that will move files based on the file type General Discussion
Batch file for moving files to folder? General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 09:00 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33