Windows 8:合并附加文件名的目录中的文件

时间:2014-11-22 15:27:41

标签: windows batch-file

我在Windows 8中工作,我希望将目录中的所有txt文件合并到一个文件中,使文件名与文件内容一起出现。

例如,如果我有两个文件,test1.txt和test2.txt,内容为: " 1 2 3" 和 " 4 五 6" 然后合并的文件应该像: - test1.txt的 1 2 3 text2.txt 4 五 6

这是否有命令行代码?感谢您的答复。

2 个答案:

答案 0 :(得分:0)

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

你可能是个蠢货

答案 1 :(得分:0)

您可以使用以下标签:

set logfile=out.txt

:onefile
set file=%1
echo %file% >> %logfile%
type %file% >> %logfile%
goto :EOF

然后使用FOR循环遍历您的文件,并每次调用它们

call :onefile %that_file%