您好我想使用批处理文件逐行合并3个文本文件。 这些行包含特殊字符char。和空间。 如果文件只有一行,下面的代码可以工作,但如果我们有多行文本ti不 因为转发是:
1stline1stline 1stline2stline 2stline1stline 2stline2stline 示例代码
@echo off
for /f "delims=" %%a in (a.txt) do (
for /f "delims=" %%b in (b.txt) do (
>>c.txt echo %%a %%b
)
)
答案 0 :(得分:2)
我刚从this site复制了答案并将其扩展为3个文件。如果没有进一步的细节,我无法提供更精确的解决方案......
@echo off
setlocal EnableDelayedExpansion
rem First file is read with FOR /F command
rem Second file is read via standard handle 3
rem Third file is read via standard handle 4
3< b.txt 4< c.txt (for /F "delims=" %%a in (a.txt) do (
rem Read next line from b.txt
set /P lineB=<&3
rem Read next line from c.txt
set /P lineC=<&4
rem Echo lines of three files
echo %%a,!lineB!,!lineC!
))