How to Merge All or Multiple Files into One File Using DOS Command

Some days ago one of my friend ask me a problem that he needs to import csv file to a SQL Server database. But the problem is there is a huge number of small files. He does not want to import one by one. He needs to merge or together all files in a single file so that he can import using SQL Server import wizard only one file. Since it was a one time job for reconciliation, I suggest him use a DOS command to merge all files into a single or one file. The DOS command is given below:

For example, you can join file1.txt and file2.txt to a new file named file3.txt:

copy/b file1.txt +file2.txt file3.txt

OR Merge All Text Files:

copy/b *.txt newfilename.txt

OR for all files in a folder:

copy/b * "newfilename_with_path"
Posted in Others

Leave a Reply

Your email address will not be published. Required fields are marked *