What I want to do is following. I want to create some bat file, that will recursively search for files starting from current directory and replace with the file that I provided
The Batch file below start from current directory, recursively search the file given in the first parameter and copy over it (with same name) the file given in second parameter:
@echo off
set targetName=%~NX1
set replacementFile=%~F2
call :processFolder
goto :EOF
:processFolder
rem For each folder in this level
for /D %%a in (*) do (
rem Enter into it, process it and go back to original
cd %%a
if exist "%targetName%" (
copy "%replacementFile%" "%targetName%" /Y
)
call :processFolder
cd ..
)
exit /B
For example:
app test1.txt c:\data\replacementfile.txt