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-08-12 05:05
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » ["Urgent"] How to judge that the current system date is equal to a certain date in batch processing? View 2,285 Replies 12
Original Poster Posted 2004-05-17 00:00 ·  中国 重庆 中电华通
初级用户
Credits 119
Posts 4
Joined 2004-05-17 00:00
22-year member
UID 24543
Gender Male
Status Offline
Does any sir know, in a batch file, how to judge whether the system date of the current computer is equal to a certain date string, and if it is, run a certain file or command? Waiting for good news! I don't want to use external tools!

Floor 2 Posted 2004-05-17 00:00 ·  中国 上海 鹏博士宽带
高级用户
★★
zhri
Credits 665
Posts 153
Joined 2004-02-23 00:00
22-year member
UID 18241
Gender Male
Status Offline
There are ways, but......

It's还算 okay.

Specific writing, I can't write it now.

But the idea is like this.

It's impossible to use the time and date commands because they require you to enter new ones to replace.

We can create a directory (such as md aa), and then judge what the creation date of this directory is.

I think these commands should be used.

md
dir
more
find
>
|
if errorlevel=.......

.......

I'm really sorry...... I forgot.
Floor 3 Posted 2004-05-18 00:00 ·  中国 重庆 中电华通
初级用户
Credits 119
Posts 4
Joined 2004-05-17 00:00
22-year member
UID 24543
Gender Male
Status Offline
Dude, could you please recall it?
Floor 4 Posted 2004-05-18 00:00 ·  中国 上海 鹏博士宽带
高级用户
★★
zhri
Credits 665
Posts 153
Joined 2004-02-23 00:00
22-year member
UID 18241
Gender Male
Status Offline
I really can't remember, dude.

I can only tell you the idea.

First, immediately create a directory (because it's more troublesome to create a file), then DIR can see the creation date of the directory.

Then use if ..... (to judge whether the strings are equal... ... if there are three usages... ... one of them... ...)

Then use more, find, and dir, and at the same time, use | (pipe), > (redirection) to write these three commands into one,

Mainly to judge whether the period of the directory you just created (displayed on the screen with dir) is equal to the string after your if... ...

......

If you can get a DOS manual, it will be easy.
Floor 5 Posted 2004-05-18 00:00 ·  中国 上海 鹏博士宽带
高级用户
★★
zhri
Credits 665
Posts 153
Joined 2004-02-23 00:00
22-year member
UID 18241
Gender Male
Status Offline
http://dos.e-stone.cn/dosbbs/dispbbs.asp?boardID=12&ID=1292

Maybe it can be a little helpful.

Really can't remember.
Floor 6 Posted 2004-05-21 00:00 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
Don't want to use external tools, just write a small program by yourself. This problem is very easy to implement with BASIC language.
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 7 Posted 2004-05-21 00:00 ·  中国 辽宁 朝阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
The specific examples can be found in the program examples provided by the BASIC program. There are corresponding example programs for MS-BASIC version 7.1 and QUICK BASIC version 4.5.
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 8 Posted 2004-05-21 00:00 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re ztb888:

This problem is not very difficult, and there are quite a number of solutions, which are based on different systems and different requirements. The complexity and skill level are also different. If we really want to describe them in detail, it can be tens of thousands of words. There are many posts about dates and times on this site. You can use the search function to browse roughly, understand various solutions, and then determine your requirements and tell us so that we can solve the problem targeted.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 9 Posted 2004-05-21 00:00 ·  中国 香港 有线电视
管理员
★★★★
專業島民
Credits 4,869
Posts 1,633
Joined 2002-12-10 00:00
23-year member
UID 465
Gender Male
Status Offline
I'll show an example:

remind.bat
-----------------
@echo off
ver|date|find "05-21">%TEMP%\$$$temp1
copy %TEMP%\$$$temp1 %TEMP%\$$$temp2>NUL
if exist %TEMP%\$$$temp2 goto remind
goto end

:remind
echo --------------------------------
echo Today is important day!
echo --------------------------------

:end
del %TEMP%\$$$temp1
del %TEMP%\$$$temp2
我的網站:http://mw16.2ya.com/ 我的網誌: http://scrappedblog.blogspot.com/
~
我的Winamp正在播放的歌曲:
Floor 10 Posted 2004-05-22 00:00 ·  中国 重庆 南岸区 电信
初级用户
Credits 257
Posts 38
Joined 2004-05-20 00:00
22-year member
UID 24855
Gender Male
Status Offline
I think the method the moderator said is very good, but it would be better if it's simpler. And according to the moderator's meaning, it seems that can't we copy empty files?
MD $$$###
DIR $$$###|FIND "05-22">NUL
IF NOT ERRORLEVEL 1 GOTO TRY
::今天不是你想要的日子
GOTO END
:TRY
::今天是真正的日子,现在你可以做你想做的事情
:END



Floor 11 Posted 2004-05-22 00:00 ·  中国 香港 有线电视
管理员
★★★★
專業島民
Credits 4,869
Posts 1,633
Joined 2002-12-10 00:00
23-year member
UID 465
Gender Male
Status Offline
Files that are empty can't be copied?
我的網站:http://mw16.2ya.com/ 我的網誌: http://scrappedblog.blogspot.com/
~
我的Winamp正在播放的歌曲:
Floor 12 Posted 2004-05-23 00:00 ·  中国 山西 太原 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re Roy:

The method you used seems to have been developed when the DOS low-version FIND didn't generate ERRORLEVEL. Now there's no need for that because most people are using high versions, and "not copying empty files" should be considered an unstandardized detail of DOS, which may be canceled in some versions.

Moreover, in localized or DOS systems that haven't solved the Y2K problem, there are potential issues with this program. For example, I want to detect whether it's May 4th, using ver|date|find "05-04">%TEMP%\$$$temp1 may confuse various states such as April 2005, May 2004, and April 5th, etc.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 13 Posted 2010-09-10 13:11 ·  中国 浙江 宁波 电信
新手上路
Credits 18
Posts 12
Joined 2010-09-01 15:18
15-year member
UID 173389
Gender Male
From 湖南益阳
Status Offline
@echo off
setlocal enabledelayedexpansion
set mm=%date:~5,2%
set dd=%date:~8,2%
if %mm% lss 10 set mm=%date:~6,1%
set /a od=!mm!-1
if !od! lss 10 set rq=0!od!
set cw=%date:~0,4%.!rq!
set /p a=Please enter the name of the area to query (just the first letter of the area):
net use z: /delete
net use z: \\10.10.103.7\Upload wang /user:administrator
dir z:\Monthly Report\%cw% |find "%a%"
if %errorlevel%==0 goto abc
goto end
:abc
mshta vbscript:CreateObject("Wscript.Shell").popup("The monthly report of the area you inquired has been submitted!",7,"System Prompt!",64)(window.close)
exit
:end
mshta vbscript:CreateObject("Wscript.Shell").popup("The monthly report of the area you inquired has not been submitted, please urge to complete it!",7,"System Prompt!",64)(window.close)
exit

I wrote this personally, hope it helps
Forum Jump: