home *** CD-ROM | disk | FTP | other *** search
Wrap
: BKUP.BTM, version 8, January 1994 : (See also BKUP.DOC for detailed description, or see :HELP below, : or type BKUP h ,or ?, [or i for syntax only].) : : (1) Creates a ZIP archive for [a] all or part of the files saved today or : [b] since a specified number of days back, or [c] since a specified : date. : (2) With the -x switch, extracts the ZIP archive(s). A selection menu : will allow file selection, or aborting the operation (by ESC). : For marking, use any of the SELECT keys (+, -, *, /, space). : : The user can specify (1) the drive to be searched (where new files : were created), and (2) drive where the archive should be created. If : no drives are specified, the default for searched drive is the default : drive, and the deafult drive for creating the updates archive is B:. : The same will apply for extraction of archives. The drive to be extracted : from (where the archive is stored) will be drive B:, and the drive to : extract to (that is, the drive to be updated) will be the default drive. : If you wish to change any of these drives permanently, look for the : '^^^' strings below and change there. If you just need to change the : drives temporarily, use the command line options (see below, :help). : =====How BKUP.BTM proceeds===== : : BKUP.BTM first creates a list of all the relevant files, then allows : you to select one of the following options: : : (*) Viewing (and handling) filenames on screen one by one : (*) Use editor to edit results (results file) : (*) View results before making any decision : (*) Go immediately to archiving (no selection) : (*) Quit (results file will remain intact) : : If you choose viewing (and handling) files on screen, the following : options are then available while working: : : (*) Accept or omit a file : (*) View a file before making a decision about it : (*) Delete a file from disk (after or before viewing) : (*) Stop selecting after a while and begin backing up (archiving) : (*) View the list of selections at each item : (*) Quit (results file will remain intact) : : When your decisions are done, this batch then : : (*) Creates a MM-DD-YY.ZIP archive ('mm-dd-yy' stand for actual date) : on drive B: (or change below to fit your needs). : OR : (*) Updates MM-DD-YY.ZIP file, if it already exists, with the newly : created list (this allows you every so often to backup files). : : If the List file (the file with the list of filenames) exists (this : batch leaves it intact), you are given the option to re-use it. This : is very useful when you haven't created new files since your last backup, : only worked on your previously created files. : : Note: ===> If you need backup for a number of days back, run this batch : with n, as indicated below. : : When extraction takes place (with switch -x), : : (*) A selection menu will allow file selection, or aborting the : operation (by ESC). For marking, use any of the SELECT keys : (+, -, *, /, space). : (*) The extracted file is marked by a 4DOS description. If you have : given your computer a "name", BKUP registers this name in the file : description upon completion of extraction. It will then stop you if : you try to extract it again to the same computer, asking you if you : wish to proceed, or go right to extraction if it's a different : computer. If the computer has no "name", it will always ask you if you : wish to extract even if it's the wrong computer. You can then "force : extract" it. If the updated files happen to already exist on the disk, : they will not be extracted anyway (even of you "force extract"). : See BKUP.DOC or type BKUP /h for explanations about naming a : computer, or just run BKUP and follow the questions. : : Each time the archive is updated, it will then be marked as such, : allowing subsequent extractions again. : : =====Customizing===== : You can change any of the parameters where '^^^' strings appear. : : =====PCTODAY.EXE===== : Note: This batch needs PCTODAY.EXE (c) by Ethan Winer. : (downloadable from SIMTEL20: <msdos.pcmag>VOL10N21.ZIP) : : Initiated by Ron Zweig (ron@ccsg.tau.ac.il). : Edited and augmented by Itamar Even-Zohar (itiez@ccsg.tau.ac.il). : : Version 7, November 1993: Fuller filename display and computer "name" : added for better information about which computer has been updated. : Version 8, January 1994: (1) A safer procedure for defining a temporary : drive added; (2) A better file selection menu replace the one-at-time : selection menu (thanks due to Sam Wilson; see label ":operate" for : details). :: ------------------------------------------------------------------ : The actual batch begins here :: ------------------------------------------------------------------ :pctoday? rem Finds out if PCTODAY.EXE is found on your path. iff "%@search[pctoday.exe]" =="" then beep text This batch needs PCTODAY.EXE (c) by Ethan Winer (downloadable from SIMTEL20: <msdos.pcmag>VOL10N21.ZIP) endtext quit endiff iff %@index[%1,h] ge 0 .or. %@index[%1,?] ge 0 then goto help elseiff %@index[%1,i] ge 0 then goto help_i endiff :compu_name if "%compuname"=="" gosub compuname setlocal :set_temp if "%temp"=="" gosub setramd : (temporary drive will be defined %_lastdisk if it is not remote : or cd-rom drive.) if not direxist %temp (set temp=^gosub setramd) iff "%@substr[%temp,0,-1]" == "\" then set temp=%temp% else set temp=%temp\ endiff iff %@index[%1,x] ge 0 then goto extract_f endiff gosub check_args iff %@index[%1,/s] ge 0 .or. %@index[%1,-s] ge 0 then set zz=%@substr[%1,2] goto _date2 elseiff %@index[%1,s] eq 0 then set zz=%@substr[%1,1] goto _date2 else goto _date1 endiff :set_defaults :_date1 set xx=%@date[%_date] : This is today'y date in full numbers since 1-1-1980 set zz=%@makedate[%@eval[%xx-%1]] : This is the actual date desired for the archive file. : If no number of days indicated by user, you get today's : date again. if %@index[%zz,0] eq 0 set zz=%@substr[%zz,1] : If a zero (0) is contained on the first position (01, etc.), : it will be removed. :_date2 set rsp=%temp%updates.rsp set zipfn=%temp%updates.zip set tmpf=%@unique[%temp] if exist %zipfn del /q %zipfn rem (This is just a precaution; this file is moved anyway, if batch rem terminates in a normal way.) :modifiables rem ==> Modify any of the following variables to your preference. set exclude=-x*.tmp -x*.00? -x*.bak -xpctoday.* -x*.zip -xkermit.* rem (filepatterns excluded from updating) set dr=%archive_drive iff %@index[%dr,:] eq 1 then set dr=%@substr[%dr,1,-1] endiff rem ('archive_drive' was determined by the 'checking drives' subroutines. rem This is the drive for the final ZIP archive; the temporary file will rem be created on your 'temp' drive, if it exists, else on deafult rem drive.) set pkz=pkzip -P -ex rem (archiving with pathnames; erase '-P' if no pathnames desired) set colordir=dirs:bright white;zip:black on white; set edt=ped.exe rem ^^^^^^^ (replace ped.exe by your preferred editor) :re-use? cls if exist %rsp goto ask goto accumulate :ask echo. gosub legenda screen 2 0 inkey /K"YNVESQ" Use extant list file? (created %@filedate[%rsp], at %@filetime[%rsp])? [time now: %_time]n (List File is: %@upper[%rsp])nnType Y/N, V(iew), S(creen), E(dit), or Q(uit) %%rep iff %rep == Q then cls^screen 2 0^set ech=echo Stopped by user^ goto end elseiff %rep == Y then goto backup elseiff %rep == V then *list %rsp^cls^goto ask elseiff %rep == E then %edt %rsp^goto backup elseiff %rep == S then echo. >%tmpf^cls^set num=0^goto edit elseiff %rep == N goto accumulate endiff :accumulate cls iff %_monitor == mono then screen 4 5 [ making a list of all new files created since %zz ] screen 3 5 Working ... else scrput 4 5 gre on whi [ making a list of all new files created since %zz ] scrput 3 5 blu on whi Working ... endiff :make_list pctoday %search_drive: /d %zz > %rsp rem (Pctoday's syntax is: PCTODAY [D:] [/D mm-dd-yyyy] [> filename.ext]) iff %@lines[%rsp] lt 0 then set ech=scrput 3 17 bri whi on bla No files were found for/since %zz! del /q %rsp goto end endiff scrput 3 17 bri whi on bla List created as %@upper[%rsp] :edit? screen 6 5 Select an option (press first letter): screen 7 5 text Screen select files on screen (one file after another) (this option allows viewing and deleting) Edit edit results file via editor View view results before making any decision Go go to immediate archiving (no selection) Quit stop now (results file will remain intact) endtext screen 16 3 inkey /K"SEQGV[ESC][Enter]" Your choice? %%rep iff %rep == G then goto backup elseiff %rep == S .or. %rep == @28 then echo. >%tmpf cls set num=0 goto edit elseiff %rep == E then %edt %rsp goto backup elseiff %rep == V then *list %rsp cls^goto edit? elseiff %rep == Q .or. %rep == %@char[27] then set ech=echo Stopped by user^goto end endiff :edit rem This procedure displays all the files saved today, one by one, : allowing you to (a) select only those you wish to back up, or : (b) delete, or (c) view a file before making a decision, or : (d) view the list of selections, or (e) stop selecting and go : to immediate archiving, or (f) quit. : iff %@eval[%num] gt %@lines[%rsp] then move /q %tmpf %rsp goto backup endiff set fn=%@line[%rsp,%num] if .%fn==. (set num=%@eval[%num+1]^goto edit) scrput 0 0 black on white Accept=A/enter Omit=O/Esc D=Delete V=View G=Begin archiving L=View list Q=Quit echo. iff %_row lt 2 then screen 2 0 endiff echo ==`>` %fn iff %_row ge %@eval[%_rows -1] then cls goto edit^endiff inkey /K"YNAODVGLQ[ESC][Enter]" A(ccept)? O(mit)? D(elete)? V(iew)? G(o)? (L)ist Q(uit)? %%rep iff %rep == %@char[27] .or. %rep == O .or. %rep == N then set num=%@eval[%num +1] goto edit :REM: see label ':note' below elseiff %rep == A .or. %rep == @28 .or. %rep == Y then echo %fn >>%tmpf set num=%@eval[%num +1] goto edit elseiff %rep == D then del /q %fn echo ==`>` %fn deleted^echo. set num=%@eval[%num +1] goto edit elseiff %rep == V then *list %fn echo.^goto edit elseiff %rep == G then set num=%@eval[%@lines[%rsp]+1] goto edit elseiff %rep == L then *list %tmpf echo.^goto edit elseiff %rep == Q then set ech=echo Stopped by user^goto end endiff :backup cdd %temp rem (Checking if there are any file at all to back up) gosub void :update rem (If zip archive exists on target diskette, update it) gosub check_drive iff exist %dr:\%zz.zip then set fn=%dr:\%zz.zip set state=old set pkz=pkzip -b%temp -P -u -ex cls gosub void %pkz %exclude %dr:\%zz.zip @%rsp gosub success goto end endiff :create_zip cls gosub void %pkz %exclude %zipfn @%rsp gosub success :check_room rem (Checking if there is room for backup file on target) iff %@diskfree[%dr:,b] lt %@filesize[%zipfn,b] then set ech=Echo No room on drive %@upper[%dr:]! %zipfn was left on %temp goto end else set ech=echo Backup archive created on drive %@upper[%dr:] endiff :move_zip gosub check_drive move /q %zipfn %dr:\%zz.zip set brand=upd set fn=%dr:\%zz.zip gosub brand :end if exist %tmpf del /q %tmpf echo. %ech echo. iff %@index[%ech,Stopped] ge 0 then goto interrupt elseiff %@index[%ech,No new] ge 0 then goto interrupt elseiff %@index[%ech,No files we] ge 0 then goto interrupt elseiff %@index[%ech,could not be] ge 0 then goto interrupt endiff if exist %dr:\%zz.zip dir /klm %dr:\%zz.zip echo. :interrupt endlocal quit :===========End of archiving part=================== :===========Begin extraction part=================== :extract_f :: Since version 8, a menu will pop up even if the archive diskette :: contains only one archive (zip) file. This will allow canceling :: extraction (by ESC). If you prefer the older procedure, you will :: have to add one more preliminary step before "select...". :set_extr_drive gosub check_args_x if not exist %arc_dr:*-?*-??.zip goto failure :extract cdd %_disk:\ set fnt=%@unique[%temp%] select /d dir /km >>%fnt (%arc_dr:*-?*-??.zip) set count=%@lines[%fnt] : iff %@lines[%fnt] eq 0 then goto immediate else goto select_file endiff :immediate cls set fn=%arc_dr:%@line[%fnt,0] set fnn=%@substr[%fn,0,15] set fn=%fnn scrput 1 0 bla on whi Extracting now NEW files from %fnn to Drive %targ_dr: rem ^^^^^^^^^^ (change colors to suit your preference) screen 2 0 if %@index[%@descript[%fn],Extracted] ge 0 gosub continue? cdd %targ_dr:\ pkunzip -d -n %fnn >&>nul set fn=%fnn gosub success_x goto end_x :select_file cls cdd %targ_dr:\ set num=-1 :operate :: This procedure written at the suggestion of Sam Wilson :: (SAM.WILSON@emerald.com), 9 Jan 1994, to whom I am grateful. :: The procedure replaces a previous one, with @select, which :: allowed file selection only one by one. set num=%@eval[%num+1] set fn=%@line[%fnt,%num] if .%fn==.**EOF** goto end_x set fn=%arc_dr:%@substr[%fn,0,15] cls scrput 1 0 bla on whi Extracting now NEW files from %fn to Drive %targ_dr: rem ^^^^^^^^^^ (change colors to suit your preference) screen 2 0 if %@index[%@descript[%fn],Extracted] ge 0 gosub continue? pkunzip -d -n %fn gosub success_x goto operate :failure echo. echo No backup files found on drive %arc_dr: endlocal quit :end_x del /q %fnt endlocal cls quit :===========End of the extraction part================== :==================SUB-ROUTINES========================= :-------sub-routine for naming your computer------------ :compuname cls screen 2 0 inkey /K"YN" Your computer has no "name"; Give it a name now? (Y/N) %%rep iff %rep == Y then goto name2 elseiff %rep == N then return endiff :name2 input Type the name you wish to call your computer: %%compuname inkey /K"YN" Read how to make it permanent? (Y/N) %%rep iff %rep == Y then set compu=on^goto name_text^return elseiff %rep == N then return endiff :-------sub-routines for the archiving part------------- :legenda screen 17 0 text Y == extant list will immediately be used for archiving N == a new list of files will be generated V == the extant list will be viewed, then you can make decision E == the list will be called by an editor S == the list will be called to screen, one file after the other Q == quit endtext drawbox 16 0 23 73 1 whi on bla return :------------------------------------------------------- :check_drive iff %@ready[%dr:] eq 0 then echo Insert diskette to Drive %@upper[%dr:], and pause endiff if not .%@search[upname.btm]==. call upname return :------------------------------------------------------- :success rem Checking results of archiving (with pkzip) iff errorlevel eq 12 then set ech=Echo (No new or updated files have been created) elseiff errorlevel ge 4 .and. errorlevel le 11 then set ech=Echo (Backup archive could not be created / updated) goto end elseiff errorlevel ge 20 then set ech=Echo (Backup archive could not be created / updated) goto end else if .%state==.old (set brand=upd^gosub brand) set ech=echo Backup archive updated on drive %@upper[%dr:] endiff return :----------------------------------------------------------- :--------sub-sub-routine for marking a file---- : This sub-routine is designed to handle marking files. To save space, : it handles both "Updated..", and "Extracted" descriptions. This can : be implemented if the different formulas are first saved on variables. :brand iff .%brand==.upd then set mark1=Updated set mark2=Updated from: set mark3=Extracted elseiff .%brand==.ext then set mark1=Extracted set mark2=Extracted to: set mark3=Updated endiff set dscr=%@descript[%fn] if "%dscr"=="" goto 1st_desc iff %@word[0,%dscr] eq %mark3 .or. "%brand" eq "upd" then set %dscr= goto 1st_desc endiff iff %@word[0,%dscr] eq %mark1 then goto add_compu endiff :add_compu if .%compuname==. (describe %fn "%dscr; %mark1; "^return) describe %fn "%dscr %compuname; " return :1st_desc iff .%compuname==. then describe %fn "%mark1; " return else describe %fn "%mark2 %compuname; " return endiff ----:canceled subroutine/ left here for prospective editors----- :void iff %@lines[%rsp] lt 0 .or. %@lines[%rsp] le 0 .and. %@len[%@line[%rsp,0]] lt 1 then set ech=scrput %@eval[%_row+1] 2 bri whi on bla No files were found /selected to back up! echo. del /q %rsp goto end else return endiff :---------(a note on canceled sub-routine)----------- :note REM This sub-routine is canceled, because although it provides REM a more elegant loop then repeating these commands with each REM 'elseiff' test, it blocks 4dos internal keystack. Therefore, REM rather than augmenting the keystack size (and subsequently REM 4dos resident portion), I preferred the less elegant solution, REM where the same text is repeated at each test. I've left this REM subroutine here, however, as a "methodological reminder". :::repeat :::set num=%@eval[%num +1] :::goto edit :::return : :-----------sub-routines for the extraction part----- :success_x iff errorlevel gt 10 .and. errorlevel lt 12 then echo (No NEW files found for extracting in %fn) if %count ge 0 (echo Press any key to continue...^pause>nul) else echo All NEW files from %fn extracted to %targ_dr: set brand=ext gosub brand endiff return :continue? iff %@index[%@descript[%fn],%compuname] ge 0 then goto force? else return endiff :force? inkey /K"EDQ" File %@upper[%fn] already extracted. E(xtract), D(elete), Q(uit)? %%rsp if %rsp == E return if %rsp == Q (echo Forced extraction canceled^goto operate) if %rsp == D (del /q %fn^echo File %fn deleted^goto operate) :-----------SUBROUTINES FOR DRIVE CHECKING----------- :check_args iff %@eval[%#] eq 0 then gosub defaults goto start_pro elseiff %@eval[%#] eq 1 then goto check_1 elseiff %@eval[%#] eq 2 then goto check_2 elseiff %@eval[%#] eq 3 then goto check_3 endiff :ask_drives inkey Search Drive (letter only)? %%se_dr inkey Archive Drive (letter only)? %%arc_dr set search_drive=%se_dr set archive_drive=%arc_dr return :check_1 iff not %@index[%1,:] ge 0 then gosub defaults goto start_pro else echo Only one drive specified! gosub ask_drives shift goto start_pro endiff :check_2 iff %@index[%1,:] ge 0 .xor. %@index[%2,:] ge 0 then gosub ask_drives shift 1 goto start_pro else set search_drive=%1 set archive_drive=%2 shift 2 goto start_pro endiff :check_3 set search_drive=%1 set archive_drive=%2 shift 2 :start_pro return rem (go back to the beginning of updating) :----subroutines for defining temporary drive---- :setramd :: (finds the first non-remote available drive/disk) set work=ZYXWVUTSRQPONMLKJIHGFEDC set dr=%_lastdisk :ramdloop set place=%@index[%work,%dr] if %_4ver lt 5 set n=0 if %_4ver ge 5 set n=1 iff %@removable[%dr] eq %n .and. %@cdrom[%dr] eq 0 .and. %@remote[%dr] eq 0 .and. %@ready[%dr] eq 1 then set ramd=%dr goto ramdname else set place=%@eval[%place+1] set dr=%@substr[%work,%place,1] endiff if %place lt 24 goto ramdloop :ramdname set temp=%ramd: return :----subroutines for checking drives for extraction--- :check_args_x shift iff %@eval[%#] eq 0 then gosub defaults_x goto start_ext elseiff %@eval[%#] eq 1 then goto check_1_x elseiff %@eval[%#] eq 2 then goto check_2_x endiff :ask_drives_x inkey Drive to extract to (letter only)? %%targ_dr inkey Drive to extract from (letter only)? %%arc_dr return :check_1_x iff not %@index[%1,:] ge 0 then gosub defaults_x goto start_ext else echo Only one drive specified! gosub ask_drives_x shift goto start_ext endiff :check_2_x iff %@index[%1,:] ge 0 .xor. %@index[%2,:] ge 0 then gosub ask_drives_x shift 1 goto start_ext else set targ_dr=%@substr[%1,1,-1] set arc_dr=%@substr[%2,1,-1] shift 2 goto start_ext endiff :start_ext return rem (go back to the beginning of updating) :----sub-sub-routines to 'checking drives'--- :defaults set search_drive=%_disk rem ^^^ modify as necessary set archive_drive=B: rem ^^^ modify as necessary return :defaults_x set targ_dr=%_disk rem ^^^ modify as necessary set arc_dr=B rem ^^^ modify as necessary return :------------end of all SUB-ROUTINES----------------- :====== HELP ===== :help cls screen 3 0 text BKUP.BTM (1) Creates a ZIP archive for [a] all or part of the files saved today, or [b] since a specified number of days back, or [c] since a specified date. (2) With the -x switch, extracts the ZIP archive(s). The user can specify (1) the drive to be searched (where new files were created), and (2) drive where the archive should be created. If no drives are specified, the default for searched drive is the default drive, and the deafult drive for creating the updates archive is B:. The same will apply for extraction of archives. The drive to be extracted from (where the archive is stored) will be drive B:, and the drive to extract to (that is, the drive to be updated) will be the default drive. If you wish to change any of these drives permanently, look for the '^^^' strings and change there. If you just need to change the drives temporarily, use the command line options (press any key for more). You can also devise aliases for your preferred updating and extraction drives, and avoid customization of this batch altogether. endtext echo (Press any key for USAGE instructions) pause >nul :help_i cls text USAGE: BKUP [<search_drive:> <archive_drive:>] [options] where, <search_drive:> is the drive which should be seached for files <archive_drive:> is the drive where the archive should be created Options are: n|-sMM-DD-YY|h|?|i|-x [<target_drive> <archive_drive:>] where [none] will create archive on drive B: for today's files on default drive. 'n' stands for 'number of days back from today'. For example, 'BK 3' will create a list since three days back from today's date. '-s' (or /s or only s) stands for 'since', followed by date, in the MM-DD-YY (month-day-year) format. For example: BK s01-29-90 will create a list of files created since 29 January 1990. 'h' (or ?, or i) stands for 'help'. 'i' shows usage screen only. '-x' (or /x or only x) extracts archive(s). <target_drive> is the drive to extract TO. <archive_drive:> is the drive to extract FROM. For full description see BKUP.DOC. endtext inkey /K"YN[ESC] [Enter]" ==`>` For instructions on "name giving" press SPACEBAR; ESC to quit. %%rep iff %rep == %@char[27] then quit elseiff %rep == @57 then goto name_text endiff :name_text cls screen 10 0 text Giving a "name" to your computers will make it easier for you to know which of your computers have been updated with BKUP. You can enter your computer name each time this batch is run, or make your computer "name" permanent. To do this, add the following line to your AUTOEXEC.BAT file: set compuname=name Where "name" stands for the actual name you wish to give it. endtext if not %compu=on goto help_p inkey /K"YN[ESC] [Enter]" ==`>` Press Enter to continue; ESC to quit %%rep iff %rep == %@char[27] then quit elseiff %rep == @28 then return >&>nul endiff :help_p inkey /K"P[ESC] [Enter]" ==`>` Press Enter or ESC to quit, P for previous HELP screen %%rep iff %rep == %@char[27] .or. %rep == @28 then quit elseiff %rep == p then goto help endiff :=====end HELP====