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 12:15
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question about batch files View 2,182 Replies 11
Original Poster Posted 2004-02-08 00:00 ·  中国 青海 西宁 电信
初级用户
Credits 157
Posts 11
Joined 2004-02-08 00:00
22-year member
UID 16934
Gender Male
Status Offline
I have a question about a batch file and would like to ask everyone.
> 1. if not exist c:\ucdos.bat goto win98
> ......
> etx cl198
> :wing98
> ......
> Here: what does this line etx cl198 mean?
>
> 2. pause > nul
>
> Question: I remember that using “pause” alone is enough to pause, so what does the “>nul” after it mean?
>
> 3. mdir c:\ah /m /f5000000
> if errorlevel 1 goto inset1
> goto help
> :inset1
> ......
> Question: what do the last 2 parameters of the command creating directory AH mean? What error is the 2nd line checking for? Is the 3rd line jumping to the HELP section?
I couldn’t find the start of HELP anywhere in the whole batch file?
>
> 4. In a batch file, just like executing .COM and .BAT, can it open .TXT and .xls documents?
> 5. In a batch file, can it determine whether a hard disk partition exists? Like in #1 where it checks whether a specified file exists, before I
execute MD F:\HYQ can I first check whether F exists?
> 6. Before I execute (by default) MD F:\HYQ, I want to give the user a prompt so the user can specify the directory name
themselves, and then use that directory name in the following commands, a bit like entering a string from the keyboard in C language. Can this be done in a batch file? How do I write it?
Floor 2 Posted 2004-02-08 00:00 ·  中国 重庆 江北区 电信
初级用户
Credits 158
Posts 10
Joined 2004-01-02 00:00
22-year member
UID 14751
Gender Male
Status Offline
To open .txt and .xls files in a batch file, you need to put type before the file, just like opening a file at the prompt.
Floor 3 Posted 2004-02-08 00:00 ·  中国 河北 唐山 联通
版主
★★★
操作系统爱好者
Credits 1,113
Posts 392
Joined 2002-11-11 00:00
23-year member
UID 228
Gender Male
Status Offline
1, I don't recognize etx. It may be a small program, because judging from the name it is not a DOS command.
2, >nul means not to display the screen output produced by the preceding command.
3, errorlevel 1 means if the error code in the result after executing the previous command is 1, then execute goto inset1
  For example, if MDIR returns 1 for successfully creating the directory, then it calls goto inset1. If it is not successful and not 1 (0 or 2, 3, ...), then it calls HELP. It should be a program section starting with :HELP. If there isn't one, then it may be calling a sub-BAT or it was just carelessness.
4, TXT can probably be opened with TYPE or EDIT, such as TYPE 1.TXT
5, There is no way. It is best to use WBAT (a batch enhancement program), which makes this very easy to do.
DOS之家 http://doshome.com 站长 葛明阳
Floor 4 Posted 2004-02-08 00:00 ·  中国 青海 西宁 电信
初级用户
Credits 157
Posts 11
Joined 2004-02-08 00:00
22-year member
UID 16934
Gender Male
Status Offline
The following is quoted from qiangqiang39 on 2004-2-8 13:37:30:
To open .txt  and .xls files in a batch file, you need to put type before the file, just like opening a file at the prompt.


I know that under DOS you can use the TYPE command to display the contents of a text file. But my batch file needs to run in WINDOWS. Can it still use the TYPE command?
Floor 5 Posted 2004-02-08 00:00 ·  中国 山西 运城 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re 5460myfriend:

I know that under DOS you can use the TYPE command to display the contents of a text file. But my batch file needs to run in WINDOWS. Can it still use the TYPE command?


Under Windows you can use start file.txt, and the system will automatically call the default program for opening Txt files, usually Notepad.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 6 Posted 2004-02-08 00:00 ·  中国 青海 西宁 电信
初级用户
Credits 157
Posts 11
Joined 2004-02-08 00:00
22-year member
UID 16934
Gender Male
Status Offline
The following is quoted from willsort on 2004-2-8 17:09:25:
Re 5460myfriend:



    Under Windows you can use start file.txt, and the system will automatically call the default program for opening Txt files, usually Notepad.


Thank you so much! Such a quick reply. If I want to open .DOC, .XLS, .WPS, and .GIF, do I also use START FILE? For example, START 12.TXT, START 34.DOC, START 56.XLS, START 78.GIF — is that OK?
Floor 7 Posted 2004-02-08 00:00 ·  中国 山西 太原 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re 5460myfriend:

Yes, as long as the corresponding file type has an associated default program.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 8 Posted 2004-02-09 00:00 ·  中国 青海 西宁 电信
初级用户
Credits 157
Posts 11
Joined 2004-02-08 00:00
22-year member
UID 16934
Gender Male
Status Offline
The following is quoted from willsort on 2004-2-8 17:37:09:
Re 5460myfriend:

    Yes, as long as the corresponding file type has an associated default program.


Thanks!
Could you also answer my questions 5 and 6?
Floor 9 Posted 2004-02-10 00:00 ·  中国 山西 运城 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re 5460myfriend:

5, you can use IF EXIST driveletter:\nul, for example:
if exist e:\nul if not exist e:\mydos\nul md e:\mydos

6, as for inputting a string, there are many discussion posts about it on this site, and I also participated in some of them. You can click “Search”, enter “字符串” or “输入” in the keyword field, choose 教学室 for the location, and select all dates.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 10 Posted 2004-02-15 00:00 ·  中国 青海 西宁 电信
初级用户
Credits 157
Posts 11
Joined 2004-02-08 00:00
22-year member
UID 16934
Gender Male
Status Offline
The following is quoted from willsort on 2004-2-10 14:57:30:
Re 5460myfriend:

    5, you can use IF EXIST driveletter:\nul, for example:
    if exist e:\nul if not exist e:\mydos\nul md e:\mydos

    6, as for inputting a string, there are many discussion posts about it on this site, and I also participated in some of them. You can click “Search”, enter “字符串” or “输入” in the keyword field, choose 教学室 for the location, and select all dates.


Thanks!
The key is the last question. I remember using CHOICE, but I’m not very good at using it! For example, I want to copy the monthly report files for all 12 months of a year into a new folder. The month and year are to be entered by the user from the keyboard. The filename format of each monthly report is YBYYMM.XLS, where YB is the required prefix for monthly reports, MM is a 2-digit month, and YY is the last 2 digits of the year. I need these two parameters to be entered from the keyboard and tied to the file. How can this be done?
Floor 11 Posted 2004-02-16 00:00 ·  中国 河北 石家庄 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re 5460myfriend:

If the input format is fixed like this, then choice can handle it. For details, you can refer to the module about password input in the following post:
http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=12&ID=8804
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 12 Posted 2004-02-17 00:00 ·  中国 青海 西宁 电信
初级用户
Credits 157
Posts 11
Joined 2004-02-08 00:00
22-year member
UID 16934
Gender Male
Status Offline
The following is quoted from willsort on 2004-2-16 7:06:47:
Re 5460myfriend:

    If the input format is fixed like this, then choice can handle it. For details, you can refer to the module about password input in the following post:
    http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=12&ID=8804


Thanks! I’ve already saved this page, but I still can’t understand it! I’ve been a bit busy lately, I’ll come find you again in March!
Forum Jump: