DOS Command to Merge Files


This entry is part 3 of 4 in the series DOS

You may have the need to merge together a few files into one file. Merging text files into one file is easy with a DOS command (or an equivalent command on a Mac). You could use the cut and paste method but that is slow and could easily lead to errors.

To do this, first copy all of the files you need to merge into the same directory. Then open a command prompt in the same directory as the location of your files. To do this you can use Windows Explorer to navigate to the folder where your files are and then press Ctrl+Shift and right click the mouse, then select Open command window here. We use a basic copy command to do the merge.

copy /b *.txt newfile.txt

This will merge all files in the current directory with a .txt extension into one file called newfile.txt.

Here is another command that I found at WikiHow.com that uses the for command.

for %f in (*.txt) do type "%f" >> output.txt
Series Navigation<< DOS Command to Append Text to a FileBackup Files with XCOPY >>

Leave a Reply