![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-12 03:20 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » ["Urgent"] How to judge that the current system date is equal to a certain date in batch processing? |
| Printable Version 2,284 / 12 |
| Floor1 ztb888 | Posted 2004-05-17 00:00 |
| 初级用户 Posts 4 Credits 119 | |
|
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!
|
|
| Floor2 zhri | Posted 2004-05-17 00:00 |
| 高级用户 Posts 153 Credits 665 | |
|
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. |
|
| Floor3 ztb888 | Posted 2004-05-18 00:00 |
| 初级用户 Posts 4 Credits 119 | |
|
Dude, could you please recall it?
|
|
| Floor4 zhri | Posted 2004-05-18 00:00 |
| 高级用户 Posts 153 Credits 665 | |
|
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. |
|
| Floor5 zhri | Posted 2004-05-18 00:00 |
| 高级用户 Posts 153 Credits 665 | |
|
http://dos.e-stone.cn/dosbbs/dispbbs.asp?boardID=12&ID=1292
Maybe it can be a little helpful. Really can't remember. |
|
| Floor6 Kinglion | Posted 2004-05-21 00:00 |
| 铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室 | |
|
Don't want to use external tools, just write a small program by yourself. This problem is very easy to implement with BASIC language.
|
|
| Floor7 Kinglion | Posted 2004-05-21 00:00 |
| 铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室 | |
|
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.
|
|
| Floor8 willsort | Posted 2004-05-21 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
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. |
|
| Floor9 Roy | Posted 2004-05-21 00:00 |
| 管理员 Posts 1,633 Credits 4,869 | |
|
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 |
|
| Floor10 SagInvoker | Posted 2004-05-22 00:00 |
| 初级用户 Posts 38 Credits 257 | |
|
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 |
|
| Floor11 Roy | Posted 2004-05-22 00:00 |
| 管理员 Posts 1,633 Credits 4,869 | |
|
Files that are empty can't be copied?
|
|
| Floor12 willsort | Posted 2004-05-23 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
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. |
|
| Floor13 yadngah1984 | Posted 2010-09-10 13:11 |
| 新手上路 Posts 12 Credits 18 From 湖南益阳 | |
|
@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 |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |