我有两个文本文件,需要像这样合并它们:
文本文件 1
[][][]
[][][]
文本文件 2
******
******
******
输出
******
[][][] ******
[][][] ******
我已经在这里看过了: https://stackoverflow.com/questions/17097036/merge-two-text-files-line-by-line-using-batch-script 它给了我这个:
for /f "delims=" %%a in (1.txt) do (
for /f "delims=" %%b in (2.txt) do (
>>3.txt echo %%a %%b
)
)
但该脚本会循环直到文本均匀。如下所示:
[][][] ******
[][][] ******
[][][] ******
[][][] ******
[][][] ******
[][][] ******
答案1
请参考解决方案这里
我再次发布该解决方案
@echo off
set f1=1.txt
set f2=2.txt
set "sep= " % tab %
(
for /f "delims=" %%a in (%f2%) do (
setlocal enabledelayedexpansion
set /p line=
echo(!line!!sep!%%a
endlocal
)
)<%f1%