|
samzj
初级用户
 
积分 30
发帖 14
注册 2006-10-15
状态 离线
|
『第 31 楼』:
使用 LLM 解释/回答一下
qwe1234567斑竹,运用出现了一个问题,当时间从00:00到09:59时就会出现错误,无法得到任何结果,其余时间段正常...主管跟我说可能是第一个0上出现了问题,请问大概有解决的方法吗...
各位知道的朋友也请讲解下..
:\Documents and Settings\Administrator>date
The current date is: 10/16/2006 Mon
Enter the new date: (mm-dd-yy)
C:\Documents and Settings\Administrator>time
The current time is: 15:56:45.35
Enter the new time:
set a=%date:~10,4%%date:~4,2%%date:~7,2%@%time:~0,2%%time:~3,2%%time:~6,2%
copy c:\test.bat test%a%.bat
Moderator qwe1234567, there is a problem when using it. When the time is from 00:00 to 09:59, an error occurs and no result can be obtained, while other time periods are normal... The supervisor told me that it might be a problem with the first 0. Is there probably a solution...
Friends who know, please also explain..
:\Documents and Settings\Administrator>date
The current date is: 10/16/2006 Mon
Enter the new date: (mm-dd-yy)
C:\Documents and Settings\Administrator>time
The current time is: 15:56:45.35
Enter the new time:
set a=%date:~10,4%%date:~4,2%%date:~7,2%@%time:~0,2%%time:~3,2%%time:~6,2%
copy c:\test.bat test%a%.bat
|
|
2006-11-6 23:41 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 32 楼』:
使用 LLM 解释/回答一下
%time%方式在00:00到09:59时没有前面的0
利用延迟变量:
setlocal EnableDelayedExpansion
set time$=%time:~0,8%&&set time$=!time$::=!&&set time$=!time$: =0!
set a=%date:~10,4%%date:~4,2%%date:~7,2%@%time$%
copy c:\test.bat test%a%.bat
不用延迟变量:
set time$=%time:~0,8%
set time$=%time$::=%
set time$=%time$: =0%
set a=%date:~10,4%%date:~4,2%%date:~7,2%@%time$%
copy c:\test.bat test%a%.bat
The `%time%` method has no leading zero from 00:00 to 09:59.
Using delayed expansion:
```batch
setlocal EnableDelayedExpansion
set time$=%time:~0,8%&&set time$=!time$::=!&&set time$=!time$: =0!
set a=%date:~10,4%%date:~4,2%%date:~7,2%@%time$%
copy c:\test.bat test%a%.bat
```
Without using delayed expansion:
```batch
set time$=%time:~0,8%
set time$=%time$::=%
set time$=%time$: =0%
set a=%date:~10,4%%date:~4,2%%date:~7,2%@%time$%
copy c:\test.bat test%a%.bat
```
|
|
2006-11-6 23:57 |
|
|
samzj
初级用户
 
积分 30
发帖 14
注册 2006-10-15
状态 离线
|
『第 33 楼』:
使用 LLM 解释/回答一下
zxcv:万分感谢,用了第二个的不用延迟变量成功了...
zxcv: Thanks a million, it worked without using the delay variable with the second one...
|
|
2006-11-7 00:32 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 34 楼』:
使用 LLM 解释/回答一下
原理:
set time$=%time:~0,8%
获取%time%(“ 9:59:45.35”)前8位,“ 9:59:45”(前第一位小于10时为空格)
set time$=%time$::=%
去处“ 9:59:45”中的“:”冒号:“ 95945”
set time$=%time$: =0%
将“ 95945”中的空格替换为“0”,“095945”
Principle:
set time$=%time:~0,8%
Get the first 8 digits of %time% ("9:59:45.35"), which is "9:59:45" (there is a space if the first digit is less than 10)
set time$=%time$::=%
Remove the colon ":" in "9:59:45" to get "95945"
set time$=%time$: =0%
Replace the space in "95945" with "0" to get "095945"
|
|
2006-11-7 04:28 |
|
|