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-07-01 19:02
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » Seeking how to simplify the interactive Q&A of DOS batch processing?? View 1,969 Replies 8
Original Poster Posted 2004-01-19 00:00 ·  中国 江苏 扬州 电信
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
Suppose you originally made GHOST backups on drives D, E, F... Z, but then forgot on which drives, but you just want to find the first backup and update it once and be done.

Suppose the command to update the backup is like this:
@echo off
Ghost.exe -CLONE,MODE=PDUMP,SRC=1:1,DST=WIN.gho -Z9 -sure -fx
bfyz.bat

If you find how many, just handle how many, as follows:

Suitable for 2000, XP, 2003:
@echo off
for %%1 in (d e f ....z) do Ghost.exe -CLONE,MODE=PDUMP,SRC=1:1,DST=%%1:\WIN.gho -Z9 -sure -fx && bfyz.bat

Suitable for 98:
(Unfortunately, now I can only separate the ghost...... and the two tasks of bfyz.bat. In 98, I haven't found a way to put these two tasks together. If someone can solve it, hurry up and post it in the post bar!!
@echo off
for %%1 in (d e f ....z) do Ghost.exe -CLONE,MODE=PDUMP,SRC=1:1,DST=%%1:\WIN.gho -Z9 -sure -fx
for %%1 in (d e f ....z) do if exist %%1:\win.gho bfyz.bat

If it is to find the first one and finish processing it, it is as follows:

@echo off
for %%1 in (z y x ....... d) do if exist %%1:\win.gho set vol=%%1
Ghost.exe -CLONE,MODE=PDUMP,SRC=1:1,DST=%vol%:\WIN.gho -Z9 -sure -fx
bfyz.bat

======================================


&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
& &
& If you are interested, you can have fun with DIY by manually entering actual parameters! &
& &
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

You can compile a simple batch processing to experiment. First, create files with contents "dddddddddddddddddddddd" and "eeeeeeeeeeeeeeeeeeeeee" respectively in the root directories of your last two drives, both named "target.txt".
======================
Compile a batch processing named "oneput.bat" as follows:
(One-time manual input)
@echo off
:loop
shift
if %1#==# goto end
if not exist %1:\target.txt goto loop
dir %1:\target.txt
type %1:\target.txt
:end

When operating, type
oneput d d e f g h i j k l m n o p q r s t u v w x y z and press Enter. (You need to enter one more arbitrary character, because shift will invalidate the first one, which is equivalent to having had a %1 in front of it)

=========================
Then compile a batch processing named "everyput.bat":
(Looks a bit scary! If someone can find a concise way, post it in the post bar! Looking forward to it! ... Seriously depressed about this!)
(Interactive manual input) Actually, this is hypothetical, because generally there are not so many drives, so just compile it according to your number of drives.

@echo off
:loop
if exist %vol%:\target.txt goto end
choice /c:defghijklmnopqrstuvwxyz /t:d,99 enter a drive letter

set vol=z
if errorlevel 23 goto loop
set vol=y
if errorlevel 22 goto loop
set vol=x
if errorlevel 21 goto loop
set vol=w
if errorlevel 20 goto loop
set vol=v
if errorlevel 19 goto loop
set vol=u
if errorlevel 18 goto loop
set vol=t
if errorlevel 17 goto loop
set vol=s
if errorlevel 16 goto loop
set vol=r
if errorlevel 15 goto loop
set vol=q
if errorlevel 14 goto loop
set vol=p
if errorlevel 13 goto loop
set vol=o
if errorlevel 12 goto loop
set vol=n
if errorlevel 11 goto loop
set vol=m
if errorlevel 10 goto loop
set vol=l
if errorlevel 9 goto loop
set vol=k
if errorlevel 8 goto loop
set vol=j
if errorlevel 7 goto loop
set vol=i
if errorlevel 6 goto loop
set vol=h
if errorlevel 5 goto loop
set vol=g
if errorlevel 4 goto loop
set vol=f
if errorlevel 3 goto loop
set vol=e
if errorlevel 2 goto loop
set vol=d
if errorlevel 1 goto loop

:end
dir %vol%:\target.txt
type %vol%:\target.txt
echo It''''s done!

When operating, type:
everyput d and press Enter (each time enter one: d......................z, until "It''''s done! " appears)
















































Floor 2 Posted 2004-01-21 00:00 ·  中国 广东 惠州 电信
初级用户
Credits 133
Posts 7
Joined 2004-01-21 00:00
22-year member
UID 15902
Gender Male
Status Offline
Floor 3 Posted 2004-01-26 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: tomsdos:

A very nice theme, but it feels like it was sorted out from the Q&A of a few people on the forum, with too few explanatory instructions, so it lacks organization.

For that one-time input program, you don't need to be so troublesome when inputting. The following program only needs to type the program name.

The necessity of interactive input is actually not very great, but the sequential assignment derived from it is worth exploring.


@echo off
if not == goto loop
call %0 d e f g h i j k l m n o p q r s t u v w x y z
goto end

:loop
if %1#==# goto end
if exist %1:\target.txt dir %1:\target.txt
if exist %1:\target.txt type %1:\target.txt
shift
goto loop

:end




※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 4 Posted 2004-01-26 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: tomsdos:

Just analyzed it and came up with a scheme for sequential assignment. Take a look and give some feedback.

@echo off
echo set tag1=%%tag1%%*> tag.bat
echo set tag2=%%tag2%%*> eval.bat
echo if == set value=%%1>> eval.bat

choice /c:abcdefgh /n enter a letter:
for %%e in (1 2 3 4 5 6 7 8) do if errorlevel %%e call tag.bat
for %%f in (a b c d e f g h) do call eval.bat %%f
echo You choose letter %value%, tag1=%tag1%, tag2=%tag2%
pause
:end
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 5 Posted 2004-01-29 00:00 ·  中国 辽宁 沈阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
Worth learning from, good!
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 6 Posted 2004-02-02 00:00 ·  中国 江苏 扬州 电信
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
This post was indeed proposed by me alone. The outline is as follows:

First, those that do not need to input actual parameters are divided into those suitable for 2000 XP 2003 and those for 98.

Then, those that play with manually inputting actual parameters are divided into inputting all at once and inputting one at a time (basically applicable to all, except that CHOICE XP cannot be used).

WILLSORT, hello! I tried your method but it seems not to work.
You said that manually inputting actual parameters is unnecessary, but I am doing this obviously to learn and test the operation process of DOS formal parameters and actual parameters, as well as our mastery ability and the fun of man-machine interaction!

Can you explain what tag1=%%tag1%%* and so on? Thank you!

Floor 7 Posted 2004-02-02 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: gotomsdos:

Which method doesn't work? I said that manual input is unnecessary, meaning it's not very practical in your example program.

tag1=%%tag1%%* The result echoed to the file is tag1=%tag1%*, now do you understand?
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 8 Posted 2004-02-02 00:00 ·  中国 江苏 扬州 电信
铂金会员
★★★★
C++启程者
Credits 5,154
Posts 1,827
Joined 2003-07-18 00:00
22-year member
UID 7105
Gender Male
Status Offline
What does the * here mean? Can you explain it?

Floor 9 Posted 2004-02-03 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:

set tag1=%tag1%*

That is, add an asterisk to variable tag1. The asterisk has no special meaning, only used for counting. You can refer to the following post:
http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=6&ID=9250
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Forum Jump: