Board logo

标题: 写的一个脚本总是报错,不知道如何修改了 [打印本页]

作者: xue0808     时间: 2010-4-12 16:26    标题: 写的一个脚本总是报错,不知道如何修改了

for /f "tokens=1,2 delims=:." %a in ( "%time%" ) do (set /a d=100%%b%%100-10 )

del /s /q /f %temp%\%b%*.tmp

echo %time:~3,1% |find "1" && del /s /q /f %temp%\5*.tmp

for /f "tokens=1,2 delims=:." %a in ( "%time%") do (set /a u=100%b%100-1 )

dir /s /b %temp% >%temp%\list.txt


提示错误:
第一句就有错,用的是xp sp2
c:\>test.bat
此时不应有 time00-10。

谢谢
作者: Hanyeguxing     时间: 2010-4-12 16:32
批处理脚本?.bat文件?

{%variable|%%variable}
必需。代表可替换的参数。使用 %variable 通过命令提示符执行 for 命令。使用 %%variable 在批处理文件中执行 for 命令。变量要区分大小写,并且必须用 Alpha 值表示,例如,%A、%B 或 %C。
引自:C:\WINDOWS\Help\NTCmds.chm::/for.htm

例如,在批处理中要这样写:
for %%a in (*) do echo.%%a
在命令行窗口内才使用:
for %a in (*) do echo.%a

[ Last edited by Hanyeguxing on 2010-4-12 at 16:35 ]
作者: xue0808     时间: 2010-4-12 16:36
thx,试下先

[ Last edited by xue0808 on 2010-4-12 at 16:39 ]
作者: xue0808     时间: 2010-4-12 16:42
谢谢很好用
作者: Hanyeguxing     时间: 2010-4-12 16:42


  Quote:
Originally posted by xue0808 at 2010-4-12 16:26:
for /f "tokens=1,2 delims=:." %a in ( "%time%" ) do (set /a d=100%%b%%100-10 )
del /s /q /f %temp%\%b%*.tmp
echo %time:~3,1% |find "1" && del /s /q /f %temp%\5*.tmp
for /f "tokens=1,2 delims=:." %a in ( "%time%") do (set /a u=100%b%100-1 )
dir /s /b %temp% >%temp%\list.txt
提示错误:
第一句就有错,用的是xp sp2
c:\>test.bat
此时不应有 time00-10。
谢谢

for /f "tokens=1,2 delims=:." %a in ( "%time%" ) do (set /a d=100%%b%%100-10 )
%a写成%%a,set /a d=100%%b%%100-10???
del /s /q /f %temp%\%b%*.tmp
%b%哪来的?
echo %time:~3,1% |find "1" && del /s /q /f %temp%\5*.tmp
for /f "tokens=1,2 delims=:." %a in ( "%time%") do (set /a u=100%b%100-1 )
%%a 写成%%a,set /a u=100%b%100-1 ???
dir /s /b %temp% >%temp%\list.txt


你要写这个批处理是干什么用的呢?
作者: xue0808     时间: 2010-4-12 17:15
%b%哪来的?         是当前的分钟

set /a d=100%%b%%100-10???   是当前的时间有前10分钟
作者: xue0808     时间: 2010-4-12 17:17
这些句子都是在坛里找的
作者: HAT     时间: 2010-4-12 19:21    标题: Re 6 楼

当前系统时间是晚上7点04分,你减一个10分钟出来看看?
作者: xue0808     时间: 2010-4-15 14:39


  Quote:
Originally posted by HAT at 2010-4-12 19:21:
当前系统时间是晚上7点04分,你减一个10分钟出来看看?

得出的负数,可以用60再修改???

用什么来识别是负数呢???

[ Last edited by xue0808 on 2010-4-15 at 14:43 ]
作者: HAT     时间: 2010-4-15 18:22    标题: Re 9 楼

如果是2011年1月1日凌晨0点01分呢?你准备如何计算?
作者: xue0808     时间: 2010-4-16 09:21
我的文件名都是以当前分钟开头的