------------replaceName.txt 通过星号隔开-----------
69a63618test.pdftest.pdf625285
------------replaceName.txt-----------
-------------------replaceFilesBySizeAndName.BAT-------------
chcp 65001
setlocal ENABLEDELAYEDEXPANSION
SET filesName=E:\replaceName.txt
SET sourceFile=E:\20220224
SET targetFile=E:\RECOVERY_MANUAL\20220224
SET “source=”
SET “target=”
SET “size=”
for /f “skip=1 tokens=1,2,3 delims=*” %%i in (%filesName%) do (
if exist “%targetFile%%%i” ( if exist “%sourceFile%%%j” (
FOR %%A IN (“%targetFile%%%i”) DO SET “target=%%~zA”
FOR %%B IN (“%sourceFile%%%j”) DO SET “source=%%~zB”
if !target! equ %%k (
if !target! equ !source! (
copy “%sourceFile%%%j” “%targetFile%%%i” /Y
echo copy “%sourceFile%%%j” “%targetFile%%%i” /Y >> %sourceFile%\replaceSuccess.txt
) else (
echo %%i %%j %%k >> %sourceFile%\replaceError.txt
echo copy “%sourceFile%\replaceError%%j” “%targetFile%%%i” /Y >> %sourceFile%\replaceError.txt
)
) else (
echo %%i %%j %%k >> %sourceFile%\replaceError.txt
echo copy “%sourceFile%\replaceError%%j” “%targetFile%%%i” /Y >> %sourceFile%\replaceError.txt
)
)
)
)
rem pause
-------------------replaceFilesBySizeAndName.BAT-------------