|
ztb888
初级用户
 
积分 119
发帖 4
注册 2004-5-17
状态 离线
|
『楼 主』:
[”急“]如何在批处理中判断系统当前日期等于某个日期?
使用 LLM 解释/回答一下
那位兄台知道,在批处理文件中判断当前计算机的系统日期是否等于某个日期字符串,如果等于,则运行某个文件或命令?静候佳音!我不希望用外来的工具!
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!
|
|
2004-5-17 00:00 |
|
|
zhri
高级用户
    zhri
积分 665
发帖 153
注册 2004-2-23
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
办法是有的,但是......
还算可以。
具体的编写,我现在写不出了。
但是思路是这个。
不可能使用time和date命令,因为他们要求你输入新的来替换
我们可以建立一个目录(比如md aa),然后判断这个目录的建立日期是什么。
我想应该要用到这些个命令。
md
dir
more
find
>
|
if errorlevel=.......
.......
真不好意思......我忘了。
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.
|
|
2004-5-17 00:00 |
|
|
ztb888
初级用户
 
积分 119
发帖 4
注册 2004-5-17
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
老大,麻繁你记起来好吗?
Dude, could you please recall it?
|
|
2004-5-18 00:00 |
|
|
zhri
高级用户
    zhri
积分 665
发帖 153
注册 2004-2-23
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
我实在想不起来了,老兄。
我只能告诉你思路。
首先,即时地建立一个目录(因为建立文件比建立目录麻烦),这时,DIR,就可以看到目录的建立日期。
然后,用if .....(判断字符串是否相等。。。。。。if有三种用法......其中的一种......)
然后用more,find,和dir,同时,用|(管道),》(重定向)把这三条命令写成一条,
主要是判断你刚才建立的这个目录的时期(用dir显示在屏幕上的),是不是和你if后面的字符串相等。。。。。。
。。。。。。
如果你能弄到本DOS手册就好办了。
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.
|
|
2004-5-18 00:00 |
|
|
zhri
高级用户
    zhri
积分 665
发帖 153
注册 2004-2-23
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
http://dos.e-stone.cn/dosbbs/dispbbs.asp?boardID=12&ID=1292
也许能有点帮助。
实在想不起来了。
http://dos.e-stone.cn/dosbbs/dispbbs.asp?boardID=12&ID=1292
Maybe it can be a little helpful.
Really can't remember.
|
|
2004-5-18 00:00 |
|
|
Kinglion
铂金会员
       痴迷DOS者
积分 5798
发帖 1924
注册 2003-6-20 来自 金獅電腦軟體工作室
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
不希望用外来的工具,就自己编写一个小程序,此问题用BASIC语言很容易实现的.
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
|
|
2004-5-21 00:00 |
|
|
Kinglion
铂金会员
       痴迷DOS者
积分 5798
发帖 1924
注册 2003-6-20 来自 金獅電腦軟體工作室
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
具体的例程见BASIC程序提供的程序例子. MS-BASIC 7.1 版, QUICK BASIC 4.5 版都有相应的例子程序.
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
|
|
2004-5-21 00:00 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
Re ztb888:
此问题并不是很难,而且有相当多的解决方案,它们基于不同系统和不同需求,复杂度和技巧性也各有不同,真要详叙,可以上万字的篇幅。本站就有很多关于日期和时间的帖子,可以使用搜索功能大概浏览一下,了解各种方案,然后确定你的需求,将它告诉我们才能有的放矢的解决问题。
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:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-5-21 00:00 |
|
|
roy
管理员
          專業島民
积分 4869
发帖 1633
注册 2002-12-10
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
我出一個範例好了:
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
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正在播放的歌曲:
 |
|
2004-5-21 00:00 |
|
|
SagInvoker
初级用户
 
积分 257
发帖 38
注册 2004-5-20
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
我觉得斑竹说的方法很好,不过再简单点就好了,而且按照斑竹的意思,好象空文件难道就不能拷了吗?
MD $$$###
DIR $$$###|FIND "05-22">NUL
IF NOT ERRORLEVEL 1 GOTO TRY
::Today isn''t what you want
GOTO END
:TRY
::Today is the real day,Now you can do what you want to do
:END
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
|
|
2004-5-22 00:00 |
|
|
roy
管理员
          專業島民
积分 4869
发帖 1633
注册 2002-12-10
状态 离线
|
|
2004-5-22 00:00 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Re Roy:
你所用的方法,似乎是在DOS低版本的FIND不产生ERRORLEVEL的时候研究出来的吧。现在用不着这样了,因为大多数人用的都是高版本,而且"空文件不拷贝"应该算是DOS未规范的细节,不知道那个版本就会被取消的。
而且在本地化的或者未解决Y2K问题的DOS系统中,此程序存在着潜在的问题。比如,我想测知是否5月4日时,使用 ver|date|find "05-04">%TEMP%\$$$temp1 可能会
混淆 05年4月,04年5月以及4月5日等各种状态。
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:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-5-23 00:00 |
|
|
yadngah1984
新手上路

积分 18
发帖 12
注册 2010-9-1 来自 湖南益阳
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
@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=请输入要查询片区名称(片区开头字母就行):
net use z: /delete
net use z: \\10.10.103.7\上传 wang /user:administrator
dir z:\月报\%cw% |find "%a%"
if %errorlevel%==0 goto abc
goto end
:abc
mshta vbscript:CreateObject("Wscript.Shell").popup("您所查询片区月报已交!",7,"系统提示!",64)(window.close)
exit
:end
mshta vbscript:CreateObject("Wscript.Shell").popup("您所查询片区月报未交,请督促完成!",7,"系统提示!",64)(window.close)
exit
我个人写的,希望有所帮助
@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
|
|
2010-9-10 13:11 |
|