[英]windows 7 batch script- if statement not working
cd C:\Users\user1\Desktop
if "%time:~0,1%" == " "
ren 85.txt %time:~1,1%.txt
else ren 85.txt %time:~o,1%.txt
pause
The script above is not working, but if I put the following line into file: 上面的脚本不起作用,但是如果我将以下行放入文件中:
ren 85.txt %time:~1,1%.txt
it is working. 这是工作。
Why is the if...else
statement above not working? 为什么上述
if...else
语句不起作用?
cd C:\Users\user1\Desktop
if "%time:~0,1%" == " " (
ren 85.txt %time:~1,1%.txt
) else (
ren 85.txt %time:~0,1%.txt
)
pause
You need a brackets , or one line if statement : if "%time:~0,1%" == " " ren 85.txt %time:~1,1%.txt
您需要使用方括号或if语句作为一行:
if "%time:~0,1%" == " " ren 85.txt %time:~1,1%.txt
o
doesn't work, try it with 0
(zero): o
不起作用,请尝试使用0
(零):
cd C:\Users\user1\Desktop if "%time:~0,1%"==" " (ren 85.txt %time:~1,1%.txt ) else ren 85.txt %time:~0,1%.txt pause
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.