![]() |
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-06 07:08 |
48,039 topics / 350,124 posts / today 2 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » How to execute different commands based on different dates under DOS |
| Printable Version 786 / 4 |
| Floor1 sunboy19 | Posted 2007-10-28 13:59 |
| 初级用户 Posts 8 Credits 20 | |
|
Experts, I'm doing data backup and need to judge by the day of the week which corresponding files to compress. How should I write the batch file? I just looked it up and someone said to use %date%, but on my system %date% only returns the date and not the day of the week. What should I do? Waiting online
|
|
| Floor2 sunboy19 | Posted 2007-10-28 14:30 |
| 初级用户 Posts 8 Credits 20 | |
|
An update on the problem: the issue that %date% only returns the date has already been solved, but now a new problem has come up. For %date% to show the time, the system date format must be set to yyyy-mm-dd dddd, but my office system requires the date format to be yyyy-mm-dd. Is it possible to set it to yyyy-mm-dd dddd before the batch command runs, and set it back to yyyy-mm-dd after it finishes?
|
|
| Floor3 sunboy19 | Posted 2007-10-28 14:33 |
| 初级用户 Posts 8 Credits 20 | |
|
regedit -s DateFormatA.reg
if %date:~-3%==Sunday call rar.bat pause regedit -s DateFormatB.reg pause In DateFormatA.reg, set the date format to yyyy-mm-dd dddd In DateFormatB.reg, set the date format to yyyy-mm-dd This doesn't work. The date doesn't get set back; it seems the second reg wasn't executed |
|
| Floor4 sunboy19 | Posted 2007-10-28 21:13 |
| 初级用户 Posts 8 Credits 20 | |
|
No reply?
|
|
| Floor5 HAT | Posted 2007-10-29 13:11 |
| 版主 Posts 5,017 Credits 9,023 | |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |