home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
16
/
JCCHDIR.ZIP
/
BATCH.ZIP
/
ALLBAK.BAT
next >
Wrap
DOS Batch File
|
1996-06-30
|
5KB
|
129 lines
@echo off
:: This file is an example-batch-file
:: -? for help, or see end of this file
:: see file allCExe for more explanations
::-------------------------------------------------------------------
:: ID, COMMAND, batFile etc.
::-------------------------------------------------------------------
set batFile=%temp%\test.bat
set id=allBak
set doThis=%COMSPEC% /e:2048/d/c allbak2.BAT %temp%\%id%.LST
set pathSet=Y
IF %1.==-?. GOTO help
IF %1.==/?. GOTO help
IF exist %temp%\%id%.LST del %temp%\%id%.LST
::^as the actual batch-file %batFile% is going to APPEND ( $g$g => >> )
:: delete this file. Note, that the actual batch file does not delete
:: this %id%.lst file itself. This could be achieved, if eg. the above delete
:: command was inserted at the start of this file with eg:
GOTO skip1
echo @IF exist %temp%\%id%.LST del %temp%\%id%.LST >%temp%\%id%.LST
::^first line, > deletes an exisiting file
type %batFile% >>%temp%\%id%.LST
::^ append batch-file to it
copy %temp%\%id%.LST %batFile% /y >nul
::^ copy this appended file back over the original batch-file
IF exist %temp%\%id%.LST del %temp%\%id%.LST >%temp%\%id%.LST
::^ delete the temporary appended file // (just for the exercise)
::
:skip1
::-------------------------------------------------------------------
:: allCExe.BAT
::-------------------------------------------------------------------
%COMSPEC%/e:2048/d/c allCExe.BAT %1 %2 %3 %4 %5 %6 %7 %8 %9
echo echo ...file: %temp%\%id%.LST >> %batFile%
::^append this command to the batch-file %batFile%
:: BTW: this is displayed twice, which might highlight the "recursive nature"
:: of the involved batch-file - note therefore that the end of a file
:: is no place to but 28423498 commands, since they would all be run
:: twice - UNLESS you avoid this of course. eg. with:
GOTO end
...just an example: these lines are "not part of" this batch-file
@echo off
IF %1.=={. GOTO g
command/e:2096/d/c%0 { %1 %2 %3 %4 %5 %6 %7 %8
IF %p%.==. GOTO trueHalt
GOTO h
...etc...
IF ... GOTO h
...etc...
IF ... GOTO trueHalt
...etc...
:h
set p=
set d=
echo ...file: I:\tmp\allBak.LST
:trueHalt
or the likes
::-------------------------------------------------------------------
:: HELP
::-------------------------------------------------------------------
:help
cls
echo %id%
echo.
echo Uses allCexe.bat, creates a batch file: %batFile%
echo.
echo The command is: %doThis%
echo.
echo NOTE, make sure %batFile% can call allBak2.bat (i.e. that allbak2.bat is
echo in a directory which is in the PATH)
echo.
echo Parameters can be given; if so, the last parameter must exactly match
echo the directory's name, eg.:
echo %id% c: bak
echo will create a batch to run
echo %doThis%
echo in all dirs which have (exactly) the name "BAK", on drive C:
echo (enter "allcexe -?" for more details/examples)
echo.
echo Note: batch-name to be entered without the .BAT suffix.
echo.
echo NOTE carefully, you can run this batch %0 "without any risk", and
echo examine its "output": %batFile%
echo %id% will not start %batFile% automatically.
echo.
pause
cls
echo The purpose of this example is to list ALL *.BAK FILES in the matched
echo directories. With "%id% bak" this will mean searching for *.bak
echo files in directories which have (exactly) the name BAK. If there are
echo no matches, there will be no such file.
echo.
echo You can test this eg. if you create a directory named BAK and put a
echo file there with *.bak extension; enter "%id% bak" which creates the
echo file %batFile%
echo then run this file which will list all *.bak - in this case at least
echo this newly created file.
echo.
echo C.EXE will use its data-base, therefore use "c -m bak" in order to
echo create the directory, or use "c . -i" after you've entered "md bak"
echo ( This example-batch-file does not evoke an Ini of C.EXE )
echo ( Also, for mkDir: see file c.hlp for substituting md )
echo.
GOTO end
:end
::-------------------------------------------------------------------
:: RESET ENV VARs
::-------------------------------------------------------------------
set batFile=
set doThis=
set id=
set ini=
set pathSet=
::jC,951107