home *** CD-ROM | disk | FTP | other *** search
- @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=allInBak
-
- set doThis=IF exist *.* move *.* %2%%p%%
- ::note %2 is substitued in this batch, and %%p%% NOT - %%p%% will
- ::be converted to %p% which will then be exampined in the created
- ::batch-file:
- :: eg: %0 c:\ g:\bak\c
- :: -> mkdir g:\bak\c%p%
- ::best to run this file with -?, then enter an example and have
- ::a look at the created file %temp%\test.bat
- ::
- ::
-
-
- set pathSet=Y
-
- set ini=C.EXE -i %1
- ::^ini all dir-paths from the source downwards (given as first parameter)
-
-
- IF %1.==-?. GOTO help
- IF %1.==/?. GOTO help
-
-
- IF %2.==. echo ...ERROR: there should be two parameters
- IF %2.==. pause
- IF %2.==. 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 BAK
- ::!!! don't forget to specify a directory match here - otherwise
- ::ALL files would be moved - i.e. you can use this to create a file
- ::which moves entire trees
- ::
-
- ::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.
- echo %id% Move all files which are in directories named BAK
- echo.
- echo Uses allCexe.bat, creates a batch file: %batFile%
- echo.
- echo The command is: %doThis%
- echo.
- echo Two parameter must be given.
- echo first: the source drive letter with a :
- echo second: the target path
- echo eg. %0 c:\ e:
- echo eg: %0 c:\ g:\bakdirs\c
- echo the ladder will move all files in all directories named BAK on drive c:
- echo to their corresponding path on g:
- echo (eg c:\dos\bak\*.* g:\bakdirs\c\dos\bak
- echo.
- echo An initialization for the source will be run. (c -i .)
- echo use dupTree.bat to create the paths beforehands.
- 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 idea is to free up space on the source-drive whilst keeping
- echo backups on another drive which can be accessed easily. Write
- echo a batch-file to keep several "generations" on the target drive
- echo.
- echo eg. if users delete a file, and this batch was run daily,
- echo you will have the *.bak files for the last 3 days easily to
- echo find on another volume - also, you easily pkzip,etc. this
- echo tree which holds all *.bak files - whilst the main disk is
- echo using the additionally available space.
- echo (see also: bak2bak.bat)
- echo.
- echo ! ...Might make more sense to use "pkzip" with deleting the original files
- echo and storing the paths, etc., however.
- echo.
- GOTO end
-
- :end
-
- ::-------------------------------------------------------------------
- :: RESET ENV VARs
- ::-------------------------------------------------------------------
-
- set batFile=
- set doThis=
- set id=
- set ini=
- set pathSet=
-
- ::jC,951107
-