标题: [日期时间] 请教:批处理for中每个循环的起始时间%time%都一样没有变化 [打印本页]
作者: yyii 时间: 2020-4-20 10:45 标题: 请教:批处理for中每个循环的起始时间%time%都一样没有变化
- @echo off
- echo starttime,%time%
- echo starttime,%time%>timeresult.txt
- for /r %%i in (*.txt) do (
- echo %%~nxi
-
- call set t1=%%time%%
-
- echo waiting 3 second ...
- ping -n 3 127.1>nul
-
- call set t2=%%time%%
-
- call echo %%t1%%,%%t2%%
- call echo %%~nxi,%%t1%%,%%t2%%>>timeresult.txt
- )
- echo endtime,%time%>>timeresult.txt
- echo endtime,%time%
- echo complete
复制代码
set t1, set t2 前不加call也试过了。
谢谢指点!
作者: Batcher 时间: 2020-4-20 11:42
回复 1# yyii - @echo off
- setlocal enabledelayedexpansion
- echo starttime,!time!
- echo starttime,!time!>timeresult.txt
- for /r %%i in (*.txt) do (
- echo %%~nxi
- set t1=!time!
- echo waiting 3 second ...
- ping -n 3 127.1 >nul
- set t2=!time!
- echo !t1!,!t2!
- echo %%~nxi,!t1!,!t2!>>timeresult.txt
- )
- echo endtime,!time!>>timeresult.txt
- echo endtime,!time!
- echo complete
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |