问题
I have to merge files in a folder to a single text file and I'm not sure how to do that
回答1:
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
回答2:
copy /b *.txt newfile.txt
make sure all the text files are in the same folder along with the .bat
回答3:
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
来源:https://stackoverflow.com/questions/25314867/how-do-you-make-a-batch-file-that-merges-files-together