![]() |
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: 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: 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: [ 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 |