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

nikoloff

New member
Local time
4:59 AM
Messages
2
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 Computer My Computer

At a glance

Windows 7 Ultimate 32bit
Computer type
PC/Desktop
OS
Windows 7 Ultimate 32bit
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 Computer My Computer

At a glance

Windows 11 x64i5 2500K @ 3.3 GHz16 GB DDR 3 @ 1600MhzMSI 1050TI 4GB OC version
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Bulid/Self made
OS
Windows 11 x64
CPU
i5 2500K @ 3.3 GHz
Motherboard
ASUS P8 Z77 V pro
Memory
16 GB DDR 3 @ 1600Mhz
Graphics Card(s)
MSI 1050TI 4GB OC version
Sound Card
On Board (Realtek HD audio)
Monitor(s) Displays
Samsung 22" LCD
Screen Resolution
1920*1080
Hard Drives
Seagate 1 TB, WD 1TB, Seagate 2 TB ( I use a lot of space)
PSU
coolermaster 750 W
Case
Coolermaster HAF912
Cooling
Coolermaster hyper 212 EVO
Keyboard
Samsung
Mouse
Dell Wireless
Internet Speed
Wireless 50 Mbps
Antivirus
AVG 2016 Internet Security
Browser
Google Chrome
Thanks for the reply but it doesn't work :( The cmd window flashes for a quick while but nothing anymore happens
 

My Computer My Computer

At a glance

Windows 7 Ultimate 32bit
Computer type
PC/Desktop
OS
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
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 Computer My Computer

At a glance

Microsoft Windows 7 Home Premium 64-bits 7601...Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz4,00 GBATI Mobility Radeon HD 5400 Series
Computer type
Laptop
Computer Manufacturer/Model Number
ACER ASPIRE 5742G
OS
Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
CPU
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
Motherboard
Acer Aspire 5742G
Memory
4,00 GB
Graphics Card(s)
ATI Mobility Radeon HD 5400 Series
Sound Card
(1) AMD High Definition Audio Device (2) Realtek High Defi
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 60 Hz
Hard Drives
WDC WD5000BEVT-22ZAT0
Back
Top