2012-10-22

Merge CSV Files - Use DOS command through batch file

Gather all the csv files you want to merge into one, and place them in the same folder, e.g. C:\Test_Folder

Open cmd.exe, redirect to the target folder:
cd C:\Test_Folder



If target folder is located at the other drive, after you input the above command line, then input target drive letter only, e.g. D:, try to refresh path status in the command line window.

Start to merge file:
copy *.csv File_Name.csv 

Once finish merging, then you will see File_Name.csv be created in the target folder, then open the file, scroll down to the bottom of the worksheet, delete merged information.

The above method is only used to merge files in one folder, if you want to merge files in many different folders at a time, open Notepad and input the example script below, then save this file as .bat format.
X:
cd X:\Test_Folder1
copy *.csv File_Name_1.csv
cd X:\Test_Folder2
copy *.csv File_Name_2.csv
cd X:\Test_Folder3
copy *.csv File_Name_3.csv
pause

No comments:

Post a Comment