more 当前离线
技术组成员
:0@echo offfor /f "delims=" %%a in ('type %0') do (set "str=%%a"&goto :out):outset "str=%str::=%"set /a "str+=1"for /f "delims=" %%a in ('type %0') do ( if not defined god ( set god=hell >%0 echo :%str% ) else ( >>%0 echo %%a ))if %str% gtr 1 (echo %str% times already) else (echo This is the first time)rem 如果上面这行有中文会出错,不解...set "god="&pause>nul&goto :%str%COPY
TOP
原帖由 pusofalse 于 2008-10-24 13:58 发表 回复more兄,好像看错题意了。第一次运行时什么也不会输出,到运行第二次时才输出“已经运行1次”。25楼同是如此的问题。
This is the first time 2 times already 3 times already 4 times already 5 times already 6 times already
@echo offset "str=echo 这里是中间那段"for /f "delims=" %%a in ('type %0') do ( if not defined god ( set "god=hell" >%0 echo %%a ) else ( if not "%%a"=="%str%" ( >>%0 echo %%a ) else ( >>%0 echo echo 这里是已经改写的中间那段 ) ))echo 这里是中间那段pauseCOPY