从语法上讲,该这样写:- @echo off
- for /f %%a in (1.txt) do (
- set /a N+=1,M=N+1
- for /f "delims=" %%b in (html.html) do (
- set "d=%%b"
- setlocal enabledelayedexpansion
- call set "d=%%d:WML=!N!%%"
- call set "d=%%d:HTML=!M!%%"
- >>!N!.html echo.!d!
- Endlocal))
- pause
复制代码 但这样会把“url=HTML.html">” 中后面的html也替换,也把如“</html>”这些也替换了,所以,如果你只想替换HTML.html中前面的HTML的话:- @echo off
- for /f %%a in (1.txt) do (
- set /a N+=1,M=N+1
- for /f "delims=" %%b in (html.html) do (set "d=%%b"
- setlocal enabledelayedexpansion
- call set "d=%%d:WML.wml=!N!.wml%%"
- call set "d=%%d:HTML.html=!M!.html%%"
- >>!N!.html echo.!d!
- Endlocal))
- pause
复制代码
如果想用call来扩展变量,那么call 的变量名不能与for扩展的变量名有重叠!
[ 本帖最后由 hanyeguxing 于 2010-4-17 21:01 编辑 ] |