簡體   English   中英

Windows 8:合並目錄中的文件並附加文件名

[英]Windows 8 : Merge files in a directory with file name appended

我在Windows 8中工作,我想將目錄中的所有txt文件合並到一個文件中,這樣文件名與文件內容一起出現。

例如,如果我有兩個文件,分別為test1.txt和test2.txt,內容為:“ 1 2 3”和“ 4 5 6”,則合並后的文件應類似於:-test1.txt 1 2 3 text2.txt 4 5 6

為此有命令行代碼嗎? 感謝您的答復。

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

你可能會喜歡

您可以使用如下標簽:

set logfile=out.txt

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

然后使用FOR循環瀏覽您的文件,然后每次都調用它們

call :onefile %that_file%

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM