Batch Script: Combine Multiple .txt Files with Line Breaks into One File
{/'title/':/'Batch Script: Combine Multiple .txt Files with Line Breaks into One File/',/'description/':/'This batch script combines the contents of all .txt files within the 'A' folder into a single 'b.txt' file, inserting a line break after each file's content./',/'keywords/':/'batch script, .txt files, combine, concatenate, line break, new line, file manipulation, Windows/',/'content/':/'@echo off//nsetlocal enabledelayedexpansion//n//nset ///'sourceFolder=A///'//nset ///'outputFile=b.txt///'//n//nREM 清空输出文件//ntype nul > ///'%outputFile%///'//n//nfor %%F in (///'%sourceFolder%//*.txt///') do (//n//tREM 读取每个.txt文件的内容//n//tset ///'content=/// '//n//tfor /f ///'usebackq delims=///' %%C in (///'%%F///') do (//n//t//tset ///'content=!content!%%C///')//n//t//n//tREM 将内容追加到输出文件中//n//techo(!content!>> ///'%outputFile%///'//n//t//n//tREM 添加换行//n//techo.>> ///'%outputFile%///'//n)//n//necho 拷贝完成!//npause/'}
原文地址: https://www.cveoy.top/t/topic/pX0y 著作权归作者所有。请勿转载和采集!