我们在文件' style.mfx'中存储了更新的许可证。我们希望发送给用户并让它以该名称静默替换旧文件。文件将始终位于c:。 我没试过这个演示。我想在批处理文件中硬编码targetName和replacementFile。
@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
cmd行甚至不工作!但是我想要批处理文件中的参数...
app teststyle.mfx c:\teststyle.mfx
c:\Users\Joseph\Desktop>replace.bat teststyle.mfx c:\teststyle.mfx
c:\Users\Joseph\Desktop>
任何帮助都将不胜感激。
答案 0 :(得分:1)
:processFolder
rem For each folder in this level
for /D %%a in (*) do (
rem Enter into it, process it and go back to original
pushd "%%a"
if exist "%targetName%" (
copy "%replacementFile%" "%targetName%" /Y
popd
)
goto :eof
pushd/popd
可用于保存并返回。
到达文件结尾将从call
ed例程返回。