@echo off
set "SrcDir1=C:\abc\New"
set "SrcDir2=D:\123\New"
set "DstDir=%~dp0合并"
xcopy "%SrcDir1%\*.txt" "%DstDir%\" /sy >nul
for /r "%DstDir%\" %%a in (*.txt) do (
set "a=%%a"
setlocal enabledelayedexpansion
set "b=!a:%DstDir%=%SrcDir2%!"
if exist "!b!" copy /b "!a!" + "!b!" "!a!"
endlocal
)
pause