China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-08 00:07
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Please provide the complete original Chinese content including the specific requirements for the batch processing so that I can accurately translate it. The current content "求个批处理,要求先检查系统时间(已解决)" is too brief. For example, what specific checks on the system time are needed? Is it to check if it's within a certain time range, or something else? Please provide the full relevant content. View 2,692 Replies 19
Original Poster Posted 2007-01-26 22:31 ·  中国 浙江 宁波 电信
新手上路
Credits 14
Posts 6
Joined 2007-01-26 21:59
19-year member
UID 77758
Gender Male
Status Offline
Please provide the batch code content so that I can help you translate it. Just the text you provided above doesn't have the actual batch code yet. Please paste the specific batch code content that needs to be translated.
Floor 2 Posted 2007-01-26 22:46 ·  中国 四川 南充 营山县 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
SET /a a=%time:~0,2%*60+%time:~3,2%
if %a% geq 480 if %a% leq 1080 (goto 下一步)
GOTO :EOF
:下一步
..........
Floor 3 Posted 2007-01-26 22:57 ·  中国 浙江 杭州 电信
初级用户
Credits 116
Posts 28
Joined 2007-01-03 05:21
19-year member
UID 75318
Gender Male
Status Offline
@Echo OFF
Set /a thisTime=%Time:~0,2%
If %thisTime% LSS 8 Goto :End
If %thisTime% GTR 17 Goto :End

Echo Time is between 8:00-17:59
:: Run some code ...
Goto :EOF

:End
Echo Time is LSS then 8:00 or GTR then 17:59

[ Last edited by SpikeKnox on 2007-1-26 at 09:59 AM ]
Floor 4 Posted 2007-01-26 23:11 ·  中国 浙江 宁波 电信
新手上路
Credits 14
Posts 6
Joined 2007-01-26 21:59
19-year member
UID 77758
Gender Male
Status Offline
Floor 5 Posted 2007-01-26 23:46 ·  中国 浙江 宁波 电信
新手上路
Credits 14
Posts 6
Joined 2007-01-26 21:59
19-year member
UID 77758
Gender Male
Status Offline
A simple trial run was done, no problem.
SpikeKnox's (content) can be understood.
Banban's computer can understand (it)
Floor 6 Posted 2007-01-27 01:06 ·  中国 北京 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Explanation of the moderator code on the second floor:




:: 『Second floor』: Moderator code of Budenbuai:


SET /a a=%time:~0,2%*60+%time:~3,2%
if %a% geq 480 if %a% leq 1080 (goto next step)
GOTO :EOF
:next step
..........





The above code (marked in red) is to take the hour in the %time% environment variable (obtained by intercepting the string method)

For example: If the time shown in %time% is: 11:15:33.01 (that is: 11 o'clock and 15 minutes), then %time:~0,2% is to take two characters from the offset 0 start in the %time% variable. What is taken is the hour.



%time:~0,2%*60, multiply the obtained hour by 60 (minutes), because one hour is 60 minutes, so the hour number obtained through the string interception function needs to be converted into the total number of minutes, so it needs to be multiplied by 60 again. Because converting hours to minutes is for the convenience of comparing a certain time range.



+%time:~3,2%, when the hour is obtained and the hour is multiplied by 60 to convert it into minutes, it is not enough, because the minute number in the %time% variable is also needed, so %time:~3,2% (if the %time% time is: 11:15:33.01) then it is to take two characters starting from offset 3 (offset is calculated from 0), these two characters are the above (blue marked) "15".
Because the number of hours has been converted into minutes, and then adding the number of minutes in %time%, the total number of minutes of the current time obtained in this way is more accurate.


Converting to the total number of minutes can make it more convenient and simple to use IF for calculation (and can also perform addition and subtraction calculations and other special times or operations on the range of dates based on this principle...).





leq 1080 (marked in green in the above code), here LEQ means less than or equal to. Its help information can be seen by using the IF /? command:

     EQU - equal
     NEQ - not equal
     LSS - less than
     LEQ - less than or equal to
     GTR - greater than
     GEQ - greater than or equal to

The meaning of the above code refers to: less than or equal to 1080 minutes (18 o'clock: there are 18 hours from 0 o'clock to 6 o'clock in the evening, which is 18 hours * 60 minutes per hour, which is 1080 minutes)

Then use minutes as the basic unit for comparison:

IF the current time is greater than or equal to 480 minutes (that is, 480/60=8 hours, which is 8 o'clock in the morning) and the current time is less than or equal to 1080 minutes (1080/60=18 hours, which is 18 o'clock in the evening), as long as the time range is between these, this is what the building owner requires: if the current time is between 8 o'clock in the morning - 18 o'clock in the evening, execute a certain command...




(Intercepting string knowledge: There is in the help information of SET /?)
(Knowledge of %time%: There is at the end of the help information of SET /? about the dynamic environment variables that can be "called")
(Knowledge of judging size and judgment: There is in the help information of IF /?)
(Knowledge of Goto: There is in the help information of GOTO /?)




For dates, a similar method of converting all to numerical values can also be used to determine the time attributes of a certain file: special applications such as being within a certain date range.

 

[ Last edited by redtek on 2007-1-26 at 12:10 PM ]
Recent Ratings for This Post ( 3 in total) Click for details
RaterScoreTime
feiying001 +1 2007-02-15 10:43
htysm +1 2007-02-16 04:02
Eblis +2 2007-03-01 07:55
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 7 Posted 2007-01-27 02:55 ·  中国 浙江 宁波 电信
新手上路
Credits 14
Posts 6
Joined 2007-01-26 21:59
19-year member
UID 77758
Gender Male
Status Offline
Bookmarked
Floor 8 Posted 2007-01-27 04:40 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
Floor 9 Posted 2007-01-29 10:29 ·  中国 河北 保定 联通
初级用户
Credits 22
Posts 10
Joined 2006-12-30 03:50
19-year member
UID 74967
Gender Male
Status Offline
Bookmarked
Floor 10 Posted 2007-02-08 22:58 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Explained in great detail
Floor 11 Posted 2007-02-13 11:24 ·  中国 山东 青岛 电信
新手上路
Credits 14
Posts 7
Joined 2007-02-13 10:11
19-year member
UID 79383
Gender Male
Status Offline
Floor 12 Posted 2007-02-13 14:26 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by Can't Help Falling in Love at 2007-1-26 09:46:
SET /a a=%time:~0,2%*60+%time:~3,2%
if %a% geq 480 if %a% leq 1080 (goto 下一步)
GOTO :EOF
:Next Step
..........

Modify to:
set /a a=%time:~0,2%%time:~3,2%
if %a% geq 800 if %a% leq 1800 (goto 下一步)
goto :eof
:Next Step
..........

This can set the time range very intuitively
Floor 13 Posted 2007-02-14 22:36 ·  中国 浙江 宁波 电信
新手上路
Credits 14
Posts 6
Joined 2007-01-26 21:59
19-year member
UID 77758
Gender Male
Status Offline
Now I can put this into the startup, and after booting, it will automatically connect to ADSL. I need to add a disconnect in the schedule. I have a time-based package from 8:00 to 18:00.)
Floor 14 Posted 2007-02-15 06:42 ·  中国 广东 珠海 电信
初级用户
Credits 57
Posts 29
Joined 2006-09-27 02:04
19-year member
UID 63754
Status Offline
Thank you very much for the detailed explanation from user 6th floor, I've learned something new again.
Floor 15 Posted 2007-03-01 07:56 ·  中国 广东 广州 白云区 电信
中级用户
★★
Credits 251
Posts 108
Joined 2007-01-07 11:33
19-year member
UID 75721
Gender Male
From 湖南==>广州
Status Offline
DOS新人.多多指導
Forum Jump: