home *** CD-ROM | disk | FTP | other *** search
/ Media Depot 5 / mediadepotvolume51993.iso / FILES / 16 / JCCHDIR.ZIP / BATCH.ZIP / ALLINBAK.BAT < prev    next >
Encoding:
DOS Batch File  |  1996-06-30  |  5.2 KB  |  153 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=allInBak
  11.  
  12. set doThis=IF exist *.* move *.* %2%%p%%
  13. ::note %2 is substitued in this batch, and %%p%% NOT - %%p%% will
  14. ::be converted to %p% which will then be exampined in the created
  15. ::batch-file:
  16. :: eg: %0 c:\ g:\bak\c
  17. :: ->   mkdir g:\bak\c%p%
  18. ::best to run this file with -?, then enter an example and have
  19. ::a look at the created file %temp%\test.bat
  20. ::
  21. ::
  22.  
  23.  
  24. set pathSet=Y
  25.  
  26. set ini=C.EXE -i %1
  27. ::^ini all dir-paths from the source downwards (given as first parameter)
  28.  
  29.  
  30. IF %1.==-?. GOTO help
  31. IF %1.==/?. GOTO help
  32.  
  33.  
  34. IF %2.==. echo ...ERROR: there should be two parameters
  35. IF %2.==. pause
  36. IF %2.==. GOTO help
  37.  
  38. IF exist %temp%\%id%.LST del %temp%\%id%.LST
  39. ::^as the actual batch-file %batFile% is going to APPEND ( $g$g  =>  >> )
  40. :: delete this file. Note, that the actual batch file does not delete
  41. :: this %id%.lst file itself. This could be achieved, if eg. the above delete
  42. :: command was inserted at the start of this file with eg:
  43. GOTO skip1
  44.  echo @IF exist %temp%\%id%.LST del %temp%\%id%.LST >%temp%\%id%.LST
  45.  ::^first line, > deletes an exisiting file
  46.  type %batFile% >>%temp%\%id%.LST
  47.  ::^ append batch-file to it
  48.  copy %temp%\%id%.LST  %batFile%  /y >nul
  49.  ::^ copy this appended file back over the original batch-file
  50.  IF exist %temp%\%id%.LST del %temp%\%id%.LST >%temp%\%id%.LST
  51.  ::^ delete the temporary appended file // (just for the exercise)
  52.  ::
  53. :skip1
  54.  
  55. ::-------------------------------------------------------------------
  56. ::                                                        allCExe.BAT
  57. ::-------------------------------------------------------------------
  58. %COMSPEC%/e:2048/d/c allCExe.BAT  BAK
  59. ::!!! don't forget to specify a directory match here - otherwise
  60. ::ALL files would be moved - i.e. you can use this to create a file
  61. ::which moves entire trees
  62. ::
  63.  
  64. ::echo echo ...file: %temp%\%id%.LST >> %batFile%
  65. ::^append this command to the batch-file %batFile%
  66. :: BTW: this is displayed twice, which might highlight the "recursive nature"
  67. ::      of the involved batch-file - note therefore that the end of a file
  68. ::      is no place to but 28423498 commands, since they would all be run
  69. ::      twice - UNLESS you avoid this of course. eg. with:
  70. GOTO end
  71.         ...just an example: these lines are "not part of" this batch-file
  72.  
  73.           @echo  off
  74.           IF %1.=={. GOTO g
  75.           command/e:2096/d/c%0 { %1 %2 %3 %4 %5 %6 %7 %8
  76.           IF %p%.==. GOTO trueHalt
  77.           GOTO h
  78.           ...etc...
  79.           IF ... GOTO h
  80.           ...etc...
  81.           IF ... GOTO trueHalt
  82.           ...etc...
  83.           :h
  84.            set p=
  85.            set d=
  86.            echo ...file: I:\tmp\allBak.LST
  87.           :trueHalt
  88.  
  89.  
  90.         or the likes
  91.  
  92. ::-------------------------------------------------------------------
  93. ::                                                               HELP
  94. ::-------------------------------------------------------------------
  95. :help
  96.  cls
  97.  echo.
  98.  echo %id% Move all files which are in directories named BAK
  99.  echo.
  100.  echo Uses allCexe.bat, creates a batch file: %batFile%
  101.  echo.
  102.  echo The command is: %doThis%
  103.  echo.
  104.  echo Two parameter must be given.
  105.  echo   first: the source drive letter with a :
  106.  echo   second: the target path
  107.  echo   eg. %0 c:\ e:
  108.  echo   eg: %0 c:\ g:\bakdirs\c
  109.  echo       the ladder will move all files in all directories named BAK on drive c:
  110.  echo       to their corresponding path on g:
  111.  echo       (eg c:\dos\bak\*.* g:\bakdirs\c\dos\bak
  112.  echo.
  113.  echo An initialization for the source will be run. (c -i .)
  114.  echo use dupTree.bat to create the paths beforehands.
  115.  echo.
  116.  echo Note: batch-name to be entered without the .BAT suffix
  117.  echo.
  118.  echo NOTE carefully, you can run this batch %0 "without any risk", and
  119.  echo examine its "output": %batFile%
  120.  echo %id% will not start %batFile% automatically.
  121.  echo.
  122.  pause
  123.  cls
  124.  echo The idea is to free up space on the source-drive whilst keeping
  125.  echo backups on another drive which can be accessed easily. Write
  126.  echo a batch-file to keep several "generations" on the target drive
  127.  echo.
  128.  echo eg. if  users delete a file, and this batch was run daily,
  129.  echo you  will have the *.bak files for the last 3 days easily to
  130.  echo find on another volume - also, you easily pkzip,etc.  this
  131.  echo tree which holds all *.bak files - whilst the main disk is
  132.  echo using the additionally available space.
  133.  echo (see also: bak2bak.bat)
  134.  echo.
  135.  echo ! ...Might make more sense to use "pkzip" with deleting the original files
  136.  echo and storing the paths, etc., however.
  137.  echo.
  138.  GOTO end
  139.  
  140. :end
  141.  
  142. ::-------------------------------------------------------------------
  143. ::                                                     RESET ENV VARs
  144. ::-------------------------------------------------------------------
  145.  
  146. set batFile=
  147. set doThis=
  148. set id=
  149. set ini=
  150. set pathSet=
  151.  
  152. ::jC,951107
  153.