home *** CD-ROM | disk | FTP | other *** search
/ Zodiac Super OZ / MEDIADEPOT.ISO / FILES / 16 / JCCHDIR.ZIP / BATCH.ZIP / DUPTREE.BAT < prev   
DOS Batch File  |  1996-06-30  |  4KB  |  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=dupTree
  11. set doThis= mkDir %2%%p%%
  12. ::note %2 is substitued in this batch, and %%p%% NOT - %%p%% will
  13. ::be converted to %p% which will then be exampined in the created
  14. ::batch-file:
  15. :: eg: %0 c:\ g:\bak\c
  16. :: ->   mkdir g:\bak\c%p%
  17. ::best to run this file with -?, then enter an example and have
  18. ::a look at the created file %temp%\test.bat
  19. :: Note - the above won't work with the root since the \ add up to \\
  20. :: (invalid)
  21. ::
  22.  
  23. set pathSet=Y
  24.  
  25. set ini=C.EXE -i . %1
  26. ::^ini all dir-paths from the source downwards (given as first parameter)
  27.  
  28.  
  29. IF %1.==-?. GOTO help
  30. IF %1.==/?. GOTO help
  31.  
  32.  
  33. IF %2.==. echo ...ERROR: two  parameters
  34. IF %2.==. pause
  35. IF %2.==. GOTO help
  36.  
  37. IF exist %temp%\%id%.LST del %temp%\%id%.LST
  38. ::^as the actual batch-file %batFile% is going to APPEND ( $g$g  =>  >> )
  39. :: delete this file. Note, that the actual batch file does not delete
  40. :: this %id%.lst file itself. This could be achieved, if eg. the above delete
  41. :: command was inserted at the start of this file with eg:
  42. GOTO skip1
  43.  echo @IF exist %temp%\%id%.LST del %temp%\%id%.LST >%temp%\%id%.LST
  44.  ::^first line, > deletes an exisiting file
  45.  type %batFile% >>%temp%\%id%.LST
  46.  ::^ append batch-file to it
  47.  copy %temp%\%id%.LST  %batFile%  /y >nul
  48.  ::^ copy this appended file back over the original batch-file
  49.  IF exist %temp%\%id%.LST del %temp%\%id%.LST >%temp%\%id%.LST
  50.  ::^ delete the temporary appended file // (just for the exercise)
  51.  ::
  52. :skip1
  53.  
  54. ::-------------------------------------------------------------------
  55. ::                                                        allCExe.BAT
  56. ::-------------------------------------------------------------------
  57. %COMSPEC%/e:2048/d/c allCExe.BAT
  58.  
  59. ::echo echo ...file: %temp%\%id%.LST >> %batFile%
  60. ::^append this command to the batch-file %batFile%
  61. :: BTW: this is displayed twice, which might highlight the "recursive nature"
  62. ::      of the involved batch-file - note therefore that the end of a file
  63. ::      is no place to but 28423498 commands, since they would all be run
  64. ::      twice - UNLESS you avoid this of course. eg. with:
  65. GOTO end
  66.         ...just an example: these lines are "not part of" this batch-file
  67.  
  68.           @echo  off
  69.           IF %1.=={. GOTO g
  70.           command/e:2096/d/c%0 { %1 %2 %3 %4 %5 %6 %7 %8
  71.           IF %p%.==. GOTO trueHalt
  72.           GOTO h
  73.           ...etc...
  74.           IF ... GOTO h
  75.           ...etc...
  76.           IF ... GOTO trueHalt
  77.           ...etc...
  78.           :h
  79.            set p=
  80.            set d=
  81.            echo ...file: I:\tmp\allBak.LST
  82.           :trueHalt
  83.  
  84.  
  85.         or the likes
  86.  
  87. ::-------------------------------------------------------------------
  88. ::                                                               HELP
  89. ::-------------------------------------------------------------------
  90. :help
  91.  cls
  92.  echo.
  93.  echo %id%   DUPLICATE TREE
  94.  echo.
  95.  echo Uses allCexe.bat, creates a batch file: %batFile%
  96.  echo The command is: %doThis%
  97.  echo.
  98.  echo Two parameter must be given.
  99.  echo   first: the start directory, eg. c:\ to start in the root  of C:
  100.  echo   second: the target directory
  101.  echo   eg: %0 c:\ e:
  102.  echo   eg: %0 c:\ g:\bak\c
  103.  echo       will create all directories below c:\ on g:\bak\c
  104.  echo       g:\bak\c must be an exisiting directory and MUST NOT
  105.  echo       end with a \ (backslash)
  106.  echo.
  107.  echo An initialization for the source will be run. (c -i .)
  108.  echo Note: Do not enter more than the batch-name (i.e. no .bat at the end)
  109.  echo.
  110.  echo NOTE carefully, you can run this batch %0 "without any risk", and
  111.  echo examine its "output": %batFile%
  112.  echo %id% will not start %batFile% automatically.
  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.