作者l8PeakNeymar (十八尖山內馬爾)
看板EZsoft
標題[請問] 合併不同資料夾的txt檔
時間Mon Jun 26 22:19:31 2017
假如要合併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指令 還是 其他軟體 能做到嗎?
謝謝!!
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.134.146.2
※ 文章網址: https://webptt.com/m.aspx?n=bbs/EZsoft/M.1498486774.A.DF7.html
1F:推 newversion: find /path -name '*.txt' -exec echo % >> all.txt 06/26 22:51
2F:→ newversion: \; -a cat "%" >> all.txt \; 06/26 22:53
3F:→ newversion: 上面錯了!! 以下更正XD 06/26 22:58
4F:→ newversion: find /path -name '*.txt' -exec echo "{}" \; -exec 06/26 22:59
5F:→ newversion: cat "{}" \; > allfiles.txt 06/26 23:00
6F:→ newversion: 以上find是GNU的find.... 不是windows的find 06/26 23:01
7F:→ hijkxyzuw: 寫成 bat 檔吧 06/28 14:36
8F:→ promnb: dir /s /b txtMerge\*.txt 就能得到file-list 06/28 21:29
9F:→ promnb: 再利用for /f 來做; 或是直接使用for /r 來做。 06/28 21:34