中国DOS联盟论坛

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-26 01:18
47,812 topics / 349,910 posts / today 0 new / 48,264 members
DOS学习入门 & 精彩文章 (教学室) » Seeking how to simplify the interactive Q&A of DOS batch processing??
Printable Version  2,047 / 8
Floor1 GOTOmsdos Posted 2004-01-19 00:00
铂金会员 Posts 1,827 Credits 5,154
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)
















































Floor2 Vicky26 Posted 2004-01-21 00:00
初级用户 Posts 7 Credits 133
Floor3 willsort Posted 2004-01-26 00:00
元老会员 Posts 1,512 Credits 4,432
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




Floor4 willsort Posted 2004-01-26 00:00
元老会员 Posts 1,512 Credits 4,432
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
Floor5 Kinglion Posted 2004-01-29 00:00
铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室
Worth learning from, good!
Floor6 GOTOmsdos Posted 2004-02-02 00:00
铂金会员 Posts 1,827 Credits 5,154
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!

Floor7 willsort Posted 2004-02-02 00:00
元老会员 Posts 1,512 Credits 4,432
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?
Floor8 GOTOmsdos Posted 2004-02-02 00:00
铂金会员 Posts 1,827 Credits 5,154
What does the * here mean? Can you explain it?

Floor9 willsort Posted 2004-02-03 00:00
元老会员 Posts 1,512 Credits 4,432
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
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023