John
John

Reputation: 75

How do you make a batch file that merges files together?

I have to merge files in a folder to a single text file and I'm not sure how to do that

Upvotes: 1

Views: 1022

Answers (3)

aashoo
aashoo

Reputation: 404

You can use simple redirection operator with command type

suppose your directory contains 3 files a.txt b.dat and myfile

then just use type * >> outfile this will copy contents of all the files to file named outfile

Upvotes: 0

3bh
3bh

Reputation: 836

Use FOR /F: http://ss64.com/nt/for_d.html

For example, to concatenate all the text files in the current directory and any subdirectories, you could do:

FOR /F "tokens=*" %G IN ('dir /b /s *.txt') DO TYPE %G >> out.txt

Upvotes: 3

tuxy117
tuxy117

Reputation: 160

copy /b *.txt newfile.txt

make sure all the text files are in the same folder along with the .bat

Upvotes: 2

Related Questions