@echo off&setlocal enabledelayedexpansion
set "fn="1.txt" "2.txt" "3.txt""
(for %%i in (%fn%) do (
for /f "delims=" %%j in ('type %%i') do (
set /a m+=1
)
for /f "delims=" %%j in ('type %%i') do (
set /a n+=1
if !n! equ !m! (
echo;%%j&set "n=0"
) else (
set /p=%%j
)
set "m=0"
))>result.txt
endlocal
pause>nul
如果对空格的要求不严格的话:
@echo off
set "fn="1.txt" "2.txt" "3.txt""
(for %%i in (%fn%) do (
for /f "delims=" %%j in ('type %%i') do (
set /p=%%j
echo;
))>result.txt
pause>nul
PS:两者产生的结果的不同之处在于第二种会在result.txt每行的末尾添加一个空格,而第一种则不会,如果不是特别要求的话推荐第二种,效率会高一些。。。