Windows batch - concatenate multiple text files into one

前端 未结 9 744
醉梦人生
醉梦人生 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:43

    Windows type command works similarly to UNIX cat.

    Example 1: Merge with file names (This will merge file1.csv & file2.csv to create concat.csv)

    type file1.csv file2.csv > concat.csv
    

    Example 2: Merge files with pattern (This will merge all files with csv extension and create concat.csv)

    When using asterisk(*) to concatenate all files. Please DON'T use same extension for target file(Eg. .csv). There should be some difference in pattern else target file will also be considered in concatenation

    type  *.csv > concat_csv.txt
    

提交回复
热议问题