![]() |
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-11 15:24 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » [Help] How to write a batch file to create a folder named with tomorrow's date |
| Printable Version 2,121 / 17 |
| Floor1 hbby | Posted 2009-03-12 11:54 |
| 中级用户 Posts 99 Credits 220 | |
|
I have a question. In WIN2003, to create a folder with the current date, you can use
md %date% to create it. How should I write a batch file to create a folder with the next day's date? Thanks. |
|
| Floor2 yishanju | Posted 2009-03-12 12:28 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
Using datex to calculate dates is very convenient
|
|
| Floor3 applecy | Posted 2009-03-12 12:38 |
| 初级用户 Posts 78 Credits 168 | |
|
datex???
What is that??? I've been lurking too long ` don't understand |
|
| Floor4 yishanju | Posted 2009-03-12 12:47 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
Search the forum.
A command-line tool for date calculation |
|
| Floor5 hbby | Posted 2009-03-12 12:51 |
| 中级用户 Posts 99 Credits 220 | |
|
No tools, just built-in system commands, okay?
|
|
| Floor6 yishanju | Posted 2009-03-12 12:54 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
Yes, but I definitely don't know how. There are already many examples on the forum for calculating time and dates.
Search for them yourself I'm also looking forward to the day when some expert starts a thread explaining in detail how to calculate time and dates and all that [ Last edited by yishanju on 2009-3-12 at 12:56 ] |
|
| Floor7 hbby | Posted 2009-03-12 13:01 |
| 中级用户 Posts 99 Credits 220 | |
|
I already searched, and there isn't a similar solution. Calling on the moderators to lend a hand!
|
|
| Floor8 yishanju | Posted 2009-03-12 17:24 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
Using datex is such a perfect thing
|
|
| Floor9 yishanju | Posted 2009-03-12 17:37 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
| Floor10 yishanju | Posted 2009-03-12 17:59 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
5 batch files for calculating day counts
http://bbs.bathome.cn/viewthread.php?tid=874&highlight=%BC%C6%CB%E3%CC%EC%CA%FD |
|
| Floor11 yishanju | Posted 2009-03-12 19:37 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
Posting the description of the VBS DateAdd function
DateAdd(interval, number, date) Arguments interval Required. A string expression that specifies the time interval to add. For values, see the "Settings" section. number Required. A numeric expression that specifies the number of time intervals to add. The numeric expression can be positive (to get a future date) or negative (to get a past date). date Required. A Variant or date literal representing the date to which interval is added. Settings The interval argument can have the following values: Setting Description yyyy Year q Quarter m Month y Day of year d Day w Weekday ww Week h Hour n Minute s Second Description You can use the DateAdd function to add or subtract a specified time interval from a date. For example, you can use DateAdd to calculate the date 30 days from today, or the time 45 minutes from now. To add a time interval in units of "days" to date, you can use "day of year" ("y"), "day" ("d"), or "weekday" ("w"). The DateAdd function does not return an invalid date. In the following example, one month is added to January 31, 1995: NewDate = DateAdd("m", 1, "31-Jan-95") In this example, DateAdd returns February 28, 1995, rather than February 31, 1995. If date is January 31, 1996, it returns February 29, 1996, because 1996 is a leap year. If the calculated date is earlier than the year 100 AD, an error occurs. If number is not a Long value, it is rounded to the nearest integer before calculation. [ Last edited by yishanju on 2009-3-12 at 19:38 ] |
|
| Floor12 yishanju | Posted 2009-03-12 19:39 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
@echo off
echo Wscript.echo dateadd("d",1,date)>vbs.vbs for /f %%d in ('cscript //nologo vbs.vbs') do echo %%d&&md %%d pause This code tested successfully on my 2003 system |
|
| Floor13 HAT | Posted 2009-03-12 23:12 |
| 版主 Posts 5,017 Credits 9,023 | |
|
There is a method for calculating date and time in the batch function library
http://www.cn-dos.net/forum/viewthread.php?tid=45204 |
|
| Floor14 yishanju | Posted 2009-03-12 23:24 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
Anything that's not code you wrote yourself is really hard to understand
|
|
| Floor15 yishanju | Posted 2009-03-12 23:33 |
| 银牌会员 Posts 1,357 Credits 1,488 | |
|
If you want to directly use its function to calculate tomorrow's date, does that mean converting the date to a day count, then adding 1, then converting it back to a date?
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |