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
nikoloff

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
archer

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
nikoloff

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
Kaktussoft

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
Thread Forum
Batch file renaming files but not double
Hello, Got another batch file question. I think I`m close but I`m overlooking something. I have some logging that will get the date of today when I log off. But now if I log off twice the file won`t rename, filename already exists. So I came with a script to just add a number behind the...
Performance & Maintenance
Batch file to copy files from C drive to USB
Hi all, To increase our backup solutions, we have decided to backup our SQL database every hour to a folder within the C drive (we couldn't get it to backup straight to a USB drive). So now we need a way (batch file best solution?) to copy these files to the USB drive, lets say every 1.05hours...
Backup and Restore
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
Batch File to Move a list of files.
Hey All, I just joined this forum to find some help on a specific topic that I've been researching for like two hours now on google. I have a list of 1300 files that I need to move from one location to another (move not copy). I've found this batch file created by Neutron16 which performs a Move...
General Discussion
How to create a batch file that will move files based on the file type
How to create a batch file that will move files based on the file type? My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent...
General Discussion
Batch file for moving files to folder?
Hello, Wanted to see if any one here wouldn't mind writing a batch file or script that would move multiple files to a target folder. Here are the specifics: HDD1 Contains Folders A,B,C,etc... Folder A contains Folder A1 which contains File A2 Folder B contains Folder B1 which contains File B2...
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 23:20.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App