Batch file 批处理脚本结束括号问题
我使用以下批处理脚本将提供的文本替换为其他文本Batch file 批处理脚本结束括号问题,batch-file,Batch File,我使用以下批处理脚本将提供的文本替换为其他文本 @echo off setlocal call :FindReplace %1 %2 %3 exit /b :FindReplace <findstr> <replstr> <file> set tmp="%temp%\tmp.txt" If not exist %temp%\_.vbs call :MakeReplace for /f "tokens=*" %%a in ('dir "%3" /s /
@echo off
setlocal
call :FindReplace %1 %2 %3
exit /b
:FindReplace <findstr> <replstr> <file>
set tmp="%temp%\tmp.txt"
If not exist %temp%\_.vbs call :MakeReplace
for /f "tokens=*" %%a in ('dir "%3" /s /b /a-d /on') do (
for /f "usebackq" %%b in (`Findstr /mic:"%~1" "%%a"`) do (
echo(&Echo Replacing "%~1" with "%~2" in file %%~nxa
<%%a cscript //nologo %temp%\_.vbs "%~1" "%~2">%tmp%
if exist %tmp% move /Y %tmp% "%%~dpnxa">nul
)
)
del %temp%\_.vbs
exit /b
:MakeReplace
>%temp%\_.vbs echo with Wscript
>>%temp%\_.vbs echo set args=.arguments
>>%temp%\_.vbs echo .StdOut.Write _
>>%temp%\_.vbs echo Replace(.StdIn.ReadAll,args(0),args(1),1,-1,1)
>>%temp%\_.vbs echo end with
由于路径中的“'),我在控制台中得到以下内容
\Apache was unexpected at this time.
请帮我避开“')。这是一个问题:将
%3”
更改为“%~3”
这就是为什么路径字符串中的字符不受保护,因为%3已被双引号引用。请使用powershell。
\Apache was unexpected at this time.