Este não é um serviço de criação de scripts e você provavelmente já teria cuidado com isso manualmente até agora, mas isso deve ser feito:
@echo off
SETLOCAL ENABLEEXTENSIONS
SET OUTFILE=%~dp0
SET OUTFILE=%OUTFILE%filematch_go.bat
echo.
echo ----------------------------------
echo File Name Match in Dir Tree
echo ----------------------------------
echo.
echo This script will create the code for another batch script which you may
echo run in order to replace all files under the Destination Path with those
echo found in the Source Folder (but only if the file names match; no other
echo checks are done). Since some hand editing is probably going to need to
echo be made we'll just output the code for another script which will complete
echo the task of doing the overwrites. This file will be saved to the same
echo directory as this script with the filename: filematch_go.bat
echo.
echo Parameters
echo ----------
echo.
echo Source Folder: %1
echo Destination Path: %2
echo Output File: %OUTFILE%
echo.
SET ATTR=%~a1
SET DIRATTR=%ATTR:~0,1%
IF /I NOT "%DIRATTR%"=="d" GOTO SRCERR
SET ATTR=%~a2
SET DIRATTR=%ATTR:~0,1%
IF /I NOT "%DIRATTR%"=="d" GOTO DSTERR
PAUSE
echo @ECHO OFF > %OUTFILE%
FOR /f "tokens=*" %%S IN ('dir /S /B "%1*.txt"') DO (
FOR /f "tokens=*" %%D IN ('dir /S /B "%2*.txt"') DO (
IF /I "%%~nxS"=="%%~nxD" (
echo COPY "%1%%~nxS" "%2%%~nxD" >> %OUTFILE%
)
)
)
GOTO ENDSCRIPT
:SRCERR
echo.
echo ERROR: The given source folder is not a valid directory.
GOTO ERROR
:DSTERR
echo.
echo ERROR: The given destination path is not a valid directory.
:ERROR
echo.
echo An error has occurred; script halted.
echo.
:USEAGE
echo.
echo Useage Instructions:
echo.
echo filematch.bat ^<source^> ^<destination^>
echo.
echo source The folder where the new files are located
echo.
echo destination The root path of the directory tree where the files are
echo to be placed.
echo.
:ENDSCRIPT
echo Done.