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

走远了吗. 提交于 2021-01-28 06:15:39

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!