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?
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
o
doesn't work, try it with 0
(zero):
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.