更新批处理而不进行常量循环

时间:2014-03-07 17:43:39

标签: batch-file

如何创建一个不经常重新循环的脚本来检查是否启用了更改?

:0
SET CHANGES=<CHECK.TXT
:1
IF %CHANGES% GTR 0 GOTO DONE
(TIMEOUT /T 1 >NUL)
GOTO 1
:DONE
ECHO CHANGES ENABLED: %CHANGES%
PAUSE >NUL

谢谢!

1 个答案:

答案 0 :(得分:0)

完成编辑(我误解了你的问题):

@echo off

for %%i in (t.t) do set oldstamp=%%~ti

:loop
for %%i in (t.t) do set newstamp=%%~ti
if not "%newstamp%"=="%oldstamp%" goto :done
timeout /t 1 >nul
goto :loop

:done
echo file has changed