我在windows8下工作,我想把一个目录中的所有txt文件合并成一个单独的文件,这样文件名就和文件内容一起出现了。
例如,如果我有两个文件,test1.txt和test2.txt,内容分别是:"1 2 3“和"4 5 6”,那么合并后的文件应该是:- test1.txt 1 2 3 text2.txt 4 5 6
有没有这样的命令行代码?感谢您的回复。
发布于 2014-11-22 23:37:48
merge_a_and_b.bat
echo a.txt > out.txt
type a.txt >> out.txt
echo. >> out.txt
echo b.txt >> out.txt
type b.txt >> out.txt你可以成为fancyer
发布于 2014-11-23 00:01:23
您可以像这样使用标签:
set logfile=out.txt
:onefile
set file=%1
echo %file% >> %logfile%
type %file% >> %logfile%
goto :EOF然后使用FOR循环遍历您的文件,并在每次调用它们
call :onefile %that_file%https://stackoverflow.com/questions/27079046
复制相似问题