I know I can use
copy *.txt newfilename.txt to merge all the text files in a folder. Is there a way to do this, but separate each merged file with a line break?
CMD has several commands you can use to accomplish this.
- Type will show the contents of a file
- >>textfile.txt will append the output to an existig file
- echo. will print an empty line
- FOR will allow you to execute one or more commands based on a set of criteria, such as all files in a directory
Using these 4 commands, you can construct a way to accomplish what you want.
If you do not want to automate this as it are only a few files and you are doing it once, forget about the FOR and do it manually. (much easier)
The command would be this:
type file1.txt >> newfile.txt echo. >> newfile.txt type file2.txt >> newfile.txt echo. >> newfile.txt type file3.txt >> newfile.txt echo. >> newfile.txt
If you need to include a FOR the command would be this:
FOR %f IN (*.txt) DO type %f >> newfile.log & echo. >> newfile.log
Do note: if the newfile.txt already exists, it will only append to it, not create a new file. Delete the old first
EDIT: corrected for and changed name. tnx Techie007 for pointing that out.
You can use the following command in dos
more file1.txt >> file2.txt
a blank line will get inserted after every file that is being merged,
this is useful when you have to merge a common file frequently.
more file1.dat >> output.dat
any extension with files that are of ascii characters can be merged and the original file will still be available unless you delete.
You can use the following command to merge and delete the second file.
copy file1.txt 00000.txt
more 00000.txt >> 11111.txt
you can merge any type of file extensions,
a blank line gets inserted after each file that is merged
commonly used extensions are .txt, .dat, .log, etc.,