没有按行查找,对所有的 指定字符串例如( a="12345" ),
按要求替换。
@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%i in ('dir /ad/b /s "e:\test\"') do (
set n=%%~ni
if exist "%%~i\label.xml" (
call set /a a=!n!*10
call set /a b=!n!*10+9
call set /a c=!n!*10+11
call set /a d=!n!*10+19
REP.vbs "%%~i\label.xml" !a! !b! !c! !d! ))
del REP.vbs
echo 完成 任意键 退出
pause>nul
exit
:sub1
>REP.vbs echo file=wscript.arguments(0)
>>REP.vbs echo a1="a="^&chr(34)^&"12345"^&chr(34)
>>REP.vbs echo b1="b="^&chr(34)^&"12350"^&chr(34)
>>REP.vbs echo c1="c="^&chr(34)^&"12365"^&chr(34)
>>REP.vbs echo d1="d="^&chr(34)^&"12370"^&chr(34)
>>REP.vbs echo a2="a="^&chr(34)^&wscript.arguments(1)^&chr(34)
>>REP.vbs echo b2="a="^&chr(34)^&wscript.arguments(2)^&chr(34)
>>REP.vbs echo c2="a="^&chr(34)^&wscript.arguments(3)^&chr(34)
>>REP.vbs echo e2="a="^&chr(34)^&wscript.arguments(4)^&chr(34)
>>REP.vbs echo set fso=createobject("scripting.filesystemobject")
>>REP.vbs echo set fil=fso.opentextfile(file)
>>REP.vbs echo S=fil.readall
>>REP.vbs echo fil.close
>>REP.vbs echo set fi=fso.opentextfile(file,2)
>>REP.vbs echo s=Replace(s,a1,a2)
>>REP.vbs echo s=Replace(s,b1,b2)
>>REP.vbs echo s=Replace(s,c1,c2)
>>REP.vbs echo s=Replace(s,d1,d2)
>>REP.vbs echo fi.write s
>>REP.vbs echo fi.close
goto :eof