|
yaomm123456
新手上路

积分 9
发帖 3
注册 2006-9-28
状态 离线
|
『楼 主』:
[请教]如何在批处理中判断日期?
使用 LLM 解释/回答一下
判断今天是否是20号
如果是就执行拷贝命令
批处理怎么编?请教
(不显示DOS运行窗更好)
谢!
————————————俺是分割线——————————————
*********************************
版务记录
*********************************
操作: 更改标题
原因: 原格式不符版规
原标题: 新手求教
执行: 3742668
处罚: 初犯,赦之。
备注: 1.建议发贴前看看置顶版规
2.如何更改标题?
点击所发贴右下角的
编辑按钮,然后进行编辑。
**********************************
Last edited by 3742668 on 2006-9-29 at 09:07 ]
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 ]
|
|
2006-9-28 06:55 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
XP下判断当天是否是系统设置中的20号,可以用 if %date:~-2% equ 20 的格式。
不显示DOS运行窗口已经是老生常谈的话题了,光靠批处理命令是实现不了的,楼主还是打消这个念头吧——除非借助第三方软件或其他语言。
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.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-9-28 07:05 |
|
|
yaomm123456
新手上路

积分 9
发帖 3
注册 2006-9-28
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
2楼的朋友
我试了,好象不行呀
Friend on the second floor,
I tried, but it seems it doesn't work.
|
|
2006-9-28 21:14 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
我记得 namem 好像说过他时间后面没有星期几的
你换这个试试看吧 %date:~8,2%
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%
|
|
2006-9-28 21:26 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
Originally posted by NaturalJ0 at 2006-9-28 21:26:
我记得 namem 好像说过他时间后面没有星期几的
你换这个试试看吧 %date:~8,2%
是的,我的时间后面有时候有星期几,但是绝大部分时候是没有的,不知道是哪个地方设置出问题了。还是你的方法要通用一点。另外,用下面截取字符的方法也可以,只不过要稍微麻烦一点:
@echo off
for /f "tokens=3 delims=-" %%i in ("%date%") do echo 当前系统日期为 %%i 日
pause
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:
@echo off
for /f "tokens=3 delims=-" %%i in ("%date%") do echo The current system date is %%i day
pause
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-9-28 21:33 |
|
|
fastslz
铂金会员
       DOS一根葱
积分 5493
发帖 2315
注册 2006-5-1 来自 上海
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
@echo off
if "%date:~8,-4%" equ "20" (
echo 这里你就是执行拷贝命令
) ELSE (
echo 今天不是20号
)
PAUSE
Last edited by fastslz on 2006-9-28 at 21:51 ]
```
@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 ]
|

第一高手 第二高手
我的小站
 |
|
2006-9-28 21:47 |
|
|
jastyg
中级用户
  
积分 219
发帖 82
注册 2005-10-29
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
%date%在XP和2000下的结果是相反的一个星期在前面一个在后面
The result of %date% under XP and 2000 is opposite, one has the week in front and the other has it at the back.
|

www.jastyg.com
www.efengchi.com |
|
2006-10-1 03:29 |
|
|
9527
银牌会员
     努力做坏人
积分 1185
发帖 438
注册 2006-8-28 来自 北京
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
是的,2000和XP的日期显示是这样的,不过楼主已经说过啦,是XP系统,其实是2000也是好处理的,用VER命令的输出判断一下系统类型,然后在进行相应的处理便是啦........
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.
|

我今后在论坛的目标就是做个超级坏人!!! |
|
2006-10-1 03:34 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
Originally posted by fastslz at 2006-9-28 21:47:
@echo off
if "%date:~8,-4%" equ "20" (
echo 这里你就是执行拷贝命令
) ELSE (
echo 今天不是20号
)
PAUSE
Last edited by fastslz on 2006 ...
执行你这个怎么成了这个了?
C:\>兀
'兀' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
????????
Originally posted by fastslz at 2006-9-28 21:47:
@echo off
if "%date:~8,-4%" equ "20" (
echo Here you execute the copy command
) ELSE (
echo Today is not the 20th
)
PAUSE
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.
????????
|
|
2006-10-1 04:03 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
不要保存成unicode的txt
Don't save as a Unicode txt
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2006-10-1 06:00 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
|
2006-10-1 09:42 |
|
|
fastslz
铂金会员
       DOS一根葱
积分 5493
发帖 2315
注册 2006-5-1 来自 上海
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
粘贴到记事本》保存类型》所有文件》?.cmd》编码还是默认的ANSI
Paste into Notepad》Save as type》All files》?.cmd》Encoding is still the default ANSI
|

第一高手 第二高手
我的小站
 |
|
2006-10-1 10:17 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
多谢!
顺便问一下,unicode 和 ansi 有什么区别?
Thanks!
By the way, what's the difference between Unicode and ANSI?
|
|
2006-10-1 11:44 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
这个问题自己搜索
This question is to be searched by yourself
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2006-10-1 12:05 |
|
|
fastslz
铂金会员
       DOS一根葱
积分 5493
发帖 2315
注册 2006-5-1 来自 上海
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
这一下子可说不明白的,引用下willsort 版主关于编码一贴
willsort at 2006-7-23 12:15:
记事本程序在保存一篇新建的文档时,如果没有指定编码类型,会使用缺省的ANSI类型(对于中文版来说,对应的就是GB码)。
而在打开一篇已创建的文档时,它会分析文档的编码类型,它首先判断文档头部有无BOM(Byte Order Mark,字节序标记,长度为2~3字节),如果有则根据其内容判断编码类型,FF、FE(Unicode),FE、FF(Unicode big endian),EF、BB、BF(UTF-8)。
因为事实上有很多非ANSI编码的文档是没有任何BOM的“纯文本”,所以对这些文档不能简单的判断为ANSI编码。而需要使用一系列的统计学算法根据文档内容来猜测文档编码。记事本使用了 IsTextUnicode 函数来判断是否为 Unicode/Unicode big endian 编码,使用 IsTextUTF8 判断是否为 UTF8 编码。
但既然是统计学算法,就难免存在误判,尤其在文档内容过短时,由于样本的容量太小,这种误判的概率会显著增大。比如那个有名的微软与联通有仇的笑话,就是记事本在打开只有"联通"二字的ANSI编码文档时,IsTextUTF8 函数将其误判为UTF8编码;同样的误判也发生在 IsTextUnicode 函数上,比如具有 “this app can break”这种具有4335结构的文档,会被误判为 Unicode 编码。
需要说明的是,这种误判的可能性是建立在文本较短且其字节位特征不被干扰的前提上的。如果将上述的文本做稍许修改(即使只是增加一个回车),则误判很难再发生。
而 yuanyong630 兄方案的特殊性在于,它的字节串不但具有Unicode特征,而且很长达到了1288字节,也就是说它的Unicode特征性很强,所以可以抵抗一些较短的不具有Unicode特征串的干扰,这是由统计学的规律所决定的。但是在干扰串稍长时,Unicode的特征将会受到显著干扰,直至被 IsTextUnicode 函数认定为非 Unicode。所以,有些朋友总是无法测试成功,应该是与附加的批处理代码长度和内容相关。大家可以测试一下中的代码。
因为其他的编辑器(比如 Word / Wordpad / EditPlus / UltraEdit)使用了更新的编码类型判断算法,所以在 Unicode 判断上改进了不少,而 UTF8 的判断仍然不尽如人意。但因为理论上来说完全准确地算法并不存在,所以我们只能依靠避免使用无BOM的非ANSI文档,或者打开文档时手动指定编码类型。
另外,如果使用记事本保存了这些误判了编码类型的文件,则将难以恢复。如果使用误判编码保存,则将给原文档加上BOM标记,则使用其他编辑器也再无法观察到原文档。如果使用 ANSI 编码保存,则原文档将会被当作 Unicode 文档而被转换,还原的可能性接近于零。
Unicode简介
http://my.opera.com/neutronstar/blog/index.dml/tag/编码
微软为什么和联通有仇
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 ]
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 ]
|

第一高手 第二高手
我的小站
 |
|
2006-10-1 12:15 |
|