Windows batch - concatenate multiple text files into one

前端 未结 9 670
醉梦人生
醉梦人生 2021-01-31 13:53

I need to create a script, which concatenates multiple text files into one. I know it\'s simple to use

type *.txt > merged.txt

But the require

9条回答
  •  轮回少年
    2021-01-31 14:58

    I am reiterating some of the other points already made, but including a 3rd example that helps when you have files across folders that you want to concatenate.

    Example 1 (files in the same folder):

    copy file1.txt+file2.txt+file3.txt file123.txt
    

    Example 2 (files in same folder):

    type *.txt > combined.txt
    

    Example 3 (files exist across multiple folders, assumes newfileoutput.txt doesn't exist):

    for /D %f in (folderName) DO type %f/filename.txt >> .\newfileoutput.txt
    

提交回复
热议问题