China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-11 14:32
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to write a batch file to create a folder named with tomorrow's date View 2,117 Replies 17
Original Poster Posted 2009-03-12 11:54 ·  中国 江西 南昌 电信
中级用户
★★
Credits 220
Posts 99
Joined 2005-08-16 01:08
20-year member
UID 41691
Status Offline
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.
Floor 2 Posted 2009-03-12 12:28 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Using datex to calculate dates is very convenient

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 3 Posted 2009-03-12 12:38 ·  中国 广西 梧州 电信
初级用户
★★
Credits 168
Posts 78
Joined 2006-12-27 09:58
19-year member
UID 74699
Gender Male
Status Offline
datex???
What is that???
I've been lurking too long ` don't understand
我抬头仰望,原来天还是跟原来一样高.
I look up to the rise, the original days or as high as the original.
Floor 4 Posted 2009-03-12 12:47 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Search the forum.
A command-line tool for date calculation

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 5 Posted 2009-03-12 12:51 ·  中国 江西 南昌 移动
中级用户
★★
Credits 220
Posts 99
Joined 2005-08-16 01:08
20-year member
UID 41691
Status Offline
No tools, just built-in system commands, okay?
Floor 6 Posted 2009-03-12 12:54 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
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 ]

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 7 Posted 2009-03-12 13:01 ·  中国 江西 南昌 移动
中级用户
★★
Credits 220
Posts 99
Joined 2005-08-16 01:08
20-year member
UID 41691
Status Offline
I already searched, and there isn't a similar solution. Calling on the moderators to lend a hand!
Floor 8 Posted 2009-03-12 17:24 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Using datex is such a perfect thing
@echo off
datex -f yyyy年MM月DD日 -o 1>d.txt
set /p d=<d.txt
echo %d%
md %d%
pause

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 9 Posted 2009-03-12 17:37 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 10 Posted 2009-03-12 17:59 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 11 Posted 2009-03-12 19:37 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
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 ]

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 12 Posted 2009-03-12 19:39 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
@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

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 13 Posted 2009-03-12 23:12 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
There is a method for calculating date and time in the batch function library
http://www.cn-dos.net/forum/viewthread.php?tid=45204
Floor 14 Posted 2009-03-12 23:24 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Anything that's not code you wrote yourself is really hard to understand

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 15 Posted 2009-03-12 23:33 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
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?

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Forum Jump: