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


  1. Posts : 2
    Windows 7 Ultimate 32bit
       #1

    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 Computer


  2. Posts : 7,379
    Windows 7 ultimate x64
       #2

    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


  3. Posts : 2
    Windows 7 Ultimate 32bit
    Thread Starter
       #3

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


  4. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #4

    nikoloff said:
    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


 

  Related Discussions
Our Sites
Site Links
About 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 13:40.
Find Us