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-01 16:51
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to make a batch file wait for input? View 2,977 Replies 4
Original Poster Posted 2006-05-25 18:31 ·  中国 江苏 苏州 电信
新手上路
Credits 10
Posts 3
Joined 2006-05-25 16:32
20-year member
UID 55986
Status Offline
Similar to %1 in a batch file, but this parameter has to be supplied together when running the batch file, and sometimes I forget. Now I want the batch file to prompt for input, and then have the rest of the batch file process it according to what was entered.

The specific problem is this: on the server I need to back up some data, but the batch file can't automatically create a directory for the current date (I looked for tutorials on the forum and it seems none of them can do it; if there is some way, that would be even better, then I wouldn't have to enter it by hand like this), so I can only use the batch file to create a directory. But sometimes I forget to pass the %1 parameter to the batch file, so it would be best if the batch file could wait for the date to be entered, then create the directory according to the entered content, and finally copy the backup files into that directory.

I'd appreciate guidance from all the experts, thanks!
Floor 2 Posted 2006-05-25 19:27 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
The matter of creating a directory named with the current date has been discussed several times on this forum; I suggest you search carefully.
You can try entering the following command:

md %date:~0,10%

Note that in different environments the format of the %date% variable may not be exactly the same, so you can adjust it yourself for reference.
Also, if you need to wait for input and reference it in a script, you can try using the set command.

@echo off
set /p var=Please enter content:
echo The content you entered is: %var%
pause>nul

These are all fairly basic. I suggest reading Help and Support more, or looking through more old forum posts.
Floor 3 Posted 2006-05-26 07:26 ·  中国 江苏 苏州 电信
新手上路
Credits 10
Posts 3
Joined 2006-05-25 16:32
20-year member
UID 55986
Status Offline
Thanks for the guidance, I really should study this properly. I hardly ever use it normally, so there are a lot of things I don't understand

But many of the commands above are only supported by the NT command line. They simply can't be used in 98 at all. Is there any other way to use this in 98? Please give me some more guidance, thanks!

[ Last edited by yc2455 on 2006-5-26 at 11:13 ]
Floor 4 Posted 2006-05-26 08:32 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re yc2455:

set /p and %date% are both features of NTCMD, and can be used in command-line environments like XP, while the DOS version in Win98 is 7.1. Compared with MS-DOS6.22 and Win95's MS-DOS7.0, its batch syntax support is basically the same except for long filename handling and some details.

As for getting the date into an environment variable under Win98 or MS-DOS and then generating a directory based on it, there have also been discussions in this section. You can search past threads. Recently I plan to organize the date issue in batch files; it may take three days to a week, and when it's done I will post it in the Batch File Room. You're welcome to check it out.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 5 Posted 2006-05-26 11:12 ·  中国 江苏 苏州 电信
新手上路
Credits 10
Posts 3
Joined 2006-05-25 16:32
20-year member
UID 55986
Status Offline
Thanks for the reply, looking forward to it.....
Forum Jump: