如何在一个txt(批处理,子文件夹)中的每个合并文件内容和所有txt的所有路径之间获取换行符?

How to get line breaks between every merged file content and all paths of all txt in one txt (batch, subfolders)?

chcp 1252
for /r "C:" %%f in (*.txt) do type "%%f" >> echo 2> "C:\x.txt"

如果我再次使用该批次,我想覆盖x.txt。 2>&1 对于获取 x.txt 中的路径和换行符很重要。我想要所有 txt 文件(这个文件夹,所有子文件夹)的路径和内容按字母顺序排列。它在单个文件中创建所有内容。但它不会覆盖现有内容,并且路径 (2>&1) 没有换行符。我该如何整合它?

(for /r "C:" %%f in (*.txt) do type "%%f")>"C:\x.txt" 2>&1

将整个 for 循环放入一个代码块中,然后将整个循环重定向一次。 2>&1 表示 "Write STDERR (Stream 2) to the same destination as STDOUT (Stream 1)"