[請問] 合併不同資料夾的txt檔

作者: l8PeakNeymar (十八尖山內馬爾)   2017-06-26 22:19:31
假如要合併D槽裡面的txtMerge資料夾中所有txt檔 然後輸出一個allfiles.txt
步驟:
打開CMD.exe
鍵入【D:】換槽
鍵入【CD txtMerge】換到D槽下面的txtMerge資料夾
鍵入【for %I in (*.txt) do @echo ==###############==%~nxI >>allfiles.txt &&
type "%~nxI" >>allfiles.txt】
這樣不但 單一資料夾中所有 txt檔合併成一個txt檔 還有顯示 個別的檔名
但是我需要 單一資料夾中包含子資料夾的 txt檔合併成一個txt檔 還有顯示 個別的路徑
請問 CMD指令 還是 其他軟體 能做到嗎?
謝謝!!
作者: newversion (海納百川)   2017-06-26 22:51:00
find /path -name '*.txt' -exec echo % >> all.txt\; -a cat "%" >> all.txt \;上面錯了!! 以下更正XDfind /path -name '*.txt' -exec echo "{}" \; -execcat "{}" \; > allfiles.txt以上find是GNU的find.... 不是windows的find
作者: hijkxyzuw (i,j,k) ×(x,y,z)   2017-06-28 14:36:00
寫成 bat 檔吧
作者: promnb   2017-06-28 21:29:00
dir /s /b txtMerge\*.txt 就能得到file-list再利用for /f 來做; 或是直接使用for /r 來做。

Links booklink

Contact Us: admin [ a t ] ucptt.com