中国DOS联盟论坛

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-09-15 13:32
47,812 topics / 349,917 posts / today 0 new / 48,268 members
DOS批处理 & 脚本技术(批处理室) » [Inquiry] How to judge the date in batch processing?
Printable Version  7,168 / 17
Floor1 yaomm123456 Posted 2006-09-28 06:55
新手上路 Posts 3 Credits 9
Determine if today is the 20th. If yes, execute the copy command. How to write the batch? Please teach. (It's better not to display the DOS running window) Thanks!


————————————I am the divider——————————————


*********************************
Board affairs record
*********************************
Operation: Change the title
Reason: The original format does not conform to the board regulations
Original title: Novice asks for advice
Execution: 3742668
Punishment: First offense, forgiven.
Remarks: 1. It is recommended to read the stickied board regulations before posting
2. How to change the title?
Click the edit button at the lower right corner of the posted post, and then edit it.
**********************************


[ Last edited by 3742668 on 2006-9-29 at 09:07 ]
Floor2 namejm Posted 2006-09-28 07:05
荣誉版主 Posts 1,737 Credits 5,226 From 成都
In XP, you can use the format `if %date:~-2% equ 20` to judge whether the current day is the 20th in the system settings.

Not displaying the DOS running window is an old - fashioned topic. It can't be achieved only by batch processing commands. The landlord should give up this idea - unless relying on third - party software or other languages.
Floor3 yaomm123456 Posted 2006-09-28 21:14
新手上路 Posts 3 Credits 9
Friend on the second floor,
I tried, but it seems it doesn't work.
Floor4 NaturalJ0 Posted 2006-09-28 21:26
银牌会员 Posts 533 Credits 1,181
I remember that namem seemed to say that there is no day of the week after his time. Try changing this to %date:~8,2%
Floor5 namejm Posted 2006-09-28 21:33
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Originally posted by NaturalJ0 at 2006-9-28 21:26:
I remember that namem seemed to say that there was no day of the week after his time
Try this for you %date:~8,2%


  Yes, sometimes there is a day of the week after my time, but most of the time there isn't. I don't know which setting is wrong. Still, your method is more universal. Also, the following method of intercepting characters can also be used, but it is a little more troublesome:
Floor6 fastslz Posted 2006-09-28 21:47
铂金会员 Posts 2,315 Credits 5,493 From 上海
```
@echo off
if "%date:~8,-4%" equ "20" (
echo Here you just execute the copy command
) ELSE (
echo Today is not the 20th
)
PAUSE
```

[ Last edited by fastslz on 2006-9-28 at 21:51 ]
Floor7 jastyg Posted 2006-10-01 03:29
中级用户 Posts 82 Credits 219
The result of %date% under XP and 2000 is opposite, one has the week in front and the other has it at the back.
Floor8 9527 Posted 2006-10-01 03:34
银牌会员 Posts 438 Credits 1,185 From 北京
Yes, the date display in 2000 and XP is like this, but the original poster has already said it. It's the XP system. Actually, it's easy to handle for 2000 too. Just judge the system type by the output of the VER command, and then perform corresponding processing.
Floor9 lxmxn Posted 2006-10-01 04:03
版主 Posts 4,938 Credits 11,386
Originally posted by fastslz at 2006-9-28 21:47:


[ Last edited by fastslz on 2006 ...


Why does executing this become this?
C:\>兀
'"兀"' is not an internal or external command, nor is it a runnable program
or batch file.

????????
Floor10 electronixtar Posted 2006-10-01 06:00
铂金会员 Posts 2,672 Credits 7,493
Don't save as a Unicode txt
Floor11 lxmxn Posted 2006-10-01 09:42
版主 Posts 4,938 Credits 11,386
Then what to save as?
Floor12 fastslz Posted 2006-10-01 10:17
铂金会员 Posts 2,315 Credits 5,493 From 上海
Paste into Notepad》Save as type》All files》?.cmd》Encoding is still the default ANSI
Floor13 lxmxn Posted 2006-10-01 11:44
版主 Posts 4,938 Credits 11,386
Thanks!
By the way, what's the difference between Unicode and ANSI?
Floor14 electronixtar Posted 2006-10-01 12:05
铂金会员 Posts 2,672 Credits 7,493
This question is to be searched by yourself
Floor15 fastslz Posted 2006-10-01 12:15
铂金会员 Posts 2,315 Credits 5,493 From 上海
This is not easy to explain in a moment. Let's quote the post about encoding by moderator willsort.

willsort at 2006-7-23 12:15:
When the Notepad program saves a newly created document, if the encoding type is not specified, it will use the default ANSI type (for the Chinese version, it corresponds to GB code).

And when opening an already created document, it will analyze the encoding type of the document. It first judges whether there is a BOM (Byte Order Mark, with a length of 2-3 bytes) at the beginning of the document. If there is, it judges the encoding type according to its content: FF, FE (Unicode), FE, FF (Unicode big endian), EF, BB, BF (UTF-8) .

Because in fact, there are many non-ANSI encoded documents that are "plain text" without any BOM, so these documents cannot be simply judged as ANSI encoding. Instead, a series of statistical algorithms are needed to guess the document encoding according to the content of the document. Notepad uses the IsTextUnicode function to judge whether it is Unicode/Unicode big endian encoding, and uses IsTextUTF8 to judge whether it is UTF8 encoding.

But since it is a statistical algorithm, there are inevitably misjudgments, especially when the document content is too short. Because the sample capacity is too small, the probability of such misjudgment will increase significantly. For example, the famous joke that Microsoft has a grudge against China Unicom is that when Notepad opens an ANSI encoded document with only "China Unicom" two characters, the IsTextUTF8 function misjudges it as UTF8 encoding ; the same misjudgment also occurs in the IsTextUnicode function. For example, a document with "this app can break" which has a 4335 structure will be misjudged as Unicode encoding .

It should be noted that the possibility of such misjudgment is based on the premise that the text is short and its byte bit characteristics are not interfered. If the above text is slightly modified (even just adding a carriage return), then misjudgment is difficult to occur again.

The particularity of brother yuanyong630's plan is that its byte string not only has Unicode characteristics, but also is as long as 1288 bytes, that is to say, its Unicode characteristics are very strong, so it can resist the interference of some short strings that do not have Unicode characteristics, which is determined by the law of statistics. However, when the interference string is a little longer, the Unicode characteristics will be significantly interfered, until the IsTextUnicode function determines that it is not Unicode. So, some friends always can't test successfully, which should be related to the length and content of the attached batch processing code. You can test the code in .

Because other editors (such as Word / Wordpad / EditPlus / UltraEdit) use updated encoding type judgment algorithms, so the improvement in Unicode judgment is quite a lot, but the judgment of UTF8 is still not satisfactory. But because theoretically a completely accurate algorithm does not exist, so we can only rely on avoiding using non-ANSI documents without BOM, or manually specifying the encoding type when opening the document.

In addition, if these files with misjudged encoding types are saved with Notepad, it will be difficult to restore. If saved with misjudged encoding, a BOM mark will be added to the original document, and other editors will no longer be able to observe the original document. If saved with ANSI encoding, the original document will be converted as a Unicode document, and the possibility of restoration is close to zero.

Introduction to Unicode
http://my.opera.com/neutronstar/blog/index.dml/tag/encoding

Why does Microsoft have a grudge against China Unicom
http://blog.vckbase.com/localvar/archive/2005/07/12/9510.aspx

Notepad bug? Encoding issue?
http://weblogs.asp.net/cumpsd/archive/2004/02/27/81098.aspx

Bush Hid The Facts
http://www.shoutwire.com/comments/16341/Bush_Hid_The_Facts


[ Last edited by fastslz on 2006-10-1 at 12:16 ]
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023