home *** CD-ROM | disk | FTP | other *** search
/ Zodiac Super OZ / MEDIADEPOT.ISO / FILES / 16 / JCCHDIR.ZIP / BATCH.ZIP / ALLBAK.BAT next >
DOS Batch File  |  1996-06-30  |  5KB  |  129 lines

  1. @echo off
  2. :: This file is an example-batch-file
  3. :: -? for help, or see end of this file
  4. :: see file allCExe for more explanations
  5. ::-------------------------------------------------------------------
  6. ::                                          ID, COMMAND, batFile etc.
  7. ::-------------------------------------------------------------------
  8. set batFile=%temp%\test.bat
  9.  
  10. set id=allBak
  11. set doThis=%COMSPEC% /e:2048/d/c allbak2.BAT %temp%\%id%.LST
  12.  
  13. set pathSet=Y
  14.  
  15. IF %1.==-?. GOTO help
  16. IF %1.==/?. GOTO help
  17.  
  18. IF exist %temp%\%id%.LST del %temp%\%id%.LST
  19. ::^as the actual batch-file %batFile% is going to APPEND ( $g$g  =>  >> )
  20. :: delete this file. Note, that the actual batch file does not delete
  21. :: this %id%.lst file itself. This could be achieved, if eg. the above delete
  22. :: command was inserted at the start of this file with eg:
  23. GOTO skip1
  24.  echo @IF exist %temp%\%id%.LST del %temp%\%id%.LST >%temp%\%id%.LST
  25.  ::^first line, > deletes an exisiting file
  26.  type %batFile% >>%temp%\%id%.LST
  27.  ::^ append batch-file to it
  28.  copy %temp%\%id%.LST  %batFile%  /y >nul
  29.  ::^ copy this appended file back over the original batch-file
  30.  IF exist %temp%\%id%.LST del %temp%\%id%.LST >%temp%\%id%.LST
  31.  ::^ delete the temporary appended file // (just for the exercise)
  32.  ::
  33. :skip1
  34.  
  35. ::-------------------------------------------------------------------
  36. ::                                                        allCExe.BAT
  37. ::-------------------------------------------------------------------
  38. %COMSPEC%/e:2048/d/c allCExe.BAT %1 %2 %3 %4 %5 %6 %7 %8 %9
  39.  
  40. echo echo ...file: %temp%\%id%.LST >> %batFile%
  41. ::^append this command to the batch-file %batFile%
  42. :: BTW: this is displayed twice, which might highlight the "recursive nature"
  43. ::      of the involved batch-file - note therefore that the end of a file
  44. ::      is no place to but 28423498 commands, since they would all be run
  45. ::      twice - UNLESS you avoid this of course. eg. with:
  46. GOTO end
  47.         ...just an example: these lines are "not part of" this batch-file
  48.  
  49.           @echo  off
  50.           IF %1.=={. GOTO g
  51.           command/e:2096/d/c%0 { %1 %2 %3 %4 %5 %6 %7 %8
  52.           IF %p%.==. GOTO trueHalt
  53.           GOTO h
  54.           ...etc...
  55.           IF ... GOTO h
  56.           ...etc...
  57.           IF ... GOTO trueHalt
  58.           ...etc...
  59.           :h
  60.            set p=
  61.            set d=
  62.            echo ...file: I:\tmp\allBak.LST
  63.           :trueHalt
  64.  
  65.  
  66.         or the likes
  67.  
  68. ::-------------------------------------------------------------------
  69. ::                                                               HELP
  70. ::-------------------------------------------------------------------
  71. :help
  72.  cls
  73.  echo %id%
  74.  echo.
  75.  echo Uses allCexe.bat, creates a batch file: %batFile%
  76.  echo.
  77.  echo The command is: %doThis%
  78.  echo.
  79.  echo NOTE, make sure %batFile% can call allBak2.bat (i.e. that allbak2.bat is
  80.  echo in a directory which is in the PATH)
  81.  echo.
  82.  echo Parameters can be given; if so, the last parameter must exactly match
  83.  echo the directory's name, eg.:
  84.  echo   %id% c: bak
  85.  echo will create a batch to run
  86.  echo   %doThis%
  87.  echo in all dirs which have (exactly) the name "BAK", on drive C:
  88.  echo (enter "allcexe -?" for more details/examples)
  89.  echo.
  90.  echo Note: batch-name to be entered without the .BAT suffix.
  91.  echo.
  92.  echo NOTE carefully, you can run this batch %0 "without any risk", and
  93.  echo examine its "output": %batFile%
  94.  echo %id% will not start %batFile% automatically.
  95.  echo.
  96.  pause
  97.  cls
  98.  echo  The purpose of this example is to list ALL *.BAK FILES in the matched
  99.  echo  directories. With "%id% bak" this will mean searching for *.bak
  100.  echo  files in directories which have (exactly) the name BAK. If there are
  101.  echo  no matches, there will be no such file.
  102.  echo.
  103.  echo  You can test this eg. if you create a directory named BAK and put a
  104.  echo  file there with *.bak extension; enter "%id% bak" which creates the
  105.  echo  file %batFile%
  106.  echo  then run this file which will list all *.bak - in this case at least
  107.  echo  this newly created file.
  108.  echo.
  109.  echo  C.EXE will use its data-base, therefore use "c -m bak" in order to
  110.  echo  create the directory, or use "c . -i" after you've entered "md bak"
  111.  echo  ( This example-batch-file does not evoke an Ini of C.EXE )
  112.  echo  ( Also, for mkDir: see file c.hlp for substituting md )
  113.  echo.
  114.  GOTO end
  115.  
  116. :end
  117.  
  118. ::-------------------------------------------------------------------
  119. ::                                                     RESET ENV VARs
  120. ::-------------------------------------------------------------------
  121.  
  122. set batFile=
  123. set doThis=
  124. set id=
  125. set ini=
  126. set pathSet=
  127.  
  128. ::jC,951107
  129.