home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / perf31.zip / perf_30 / AUTODSAV.CMD next >
OS/2 REXX Batch file  |  1994-10-27  |  5KB  |  192 lines

  1. /* Save Desktop Directory & INIs*/
  2. /*Copyright (c) 1994 CLEAR & SIMPLE, INC.*/
  3. arg SaveInterval SaveDrive
  4. if SaveInterval='' | SaveDrive='' then do
  5. say 'The format of AutoDsav is as follows:'
  6. say;say '      AutoDsav  interval  d:\directory'
  7. say;say 'Where interval is the number of days to wait'
  8. say 'between desk save operations.  And d:\directory is'
  9. say 'a fully qualified path where AutoDsav will save'
  10. say 'the two alternating desktop backups.'
  11. say;say 'For more information please see the documentation.'
  12. say;say 'Press Enter to end...'
  13. pull
  14. exit
  15. end  /* Do */
  16.  
  17. ECHO OFF
  18. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  19. call SysLoadFuncs
  20. today=date('U')
  21. parse var today month.0 '/' day.0 '/' year.0; clock=time();
  22. rc=SysFileTree(SaveDrive'\P21autod.*',autodir,'DT')
  23.  
  24. if autodir.0 < 2 then do; 
  25.                 If autodir.0=0 then do; call desks savedrive'\p21autod.1'; exit; end;
  26.                                 else do; call desks savedrive'\p21autod.2'; exit; end;
  27.                 end;
  28.  
  29. else call datecheck
  30.  
  31. call ElimDir file.old
  32. call desks file.old
  33. exit
  34.  
  35. DateCheck:
  36. say autodir.0
  37. say autodir.1
  38. say autodir.2
  39.  
  40. parse var autodir.1 year.1'/'month.1'/'day.1'/'tim.1  size.1 att.1 file.1
  41. parse var autodir.2 year.2'/'month.2'/'day.2 '/'tim.2 size.2 att.2 file.2
  42.  
  43. call julian year.1 month.1 day.1
  44. jdat.1=result
  45.  
  46. call julian year.2 month.2 day.2
  47. jdat.2=result
  48.  
  49. call julian year.0 month.0 day.0
  50. jdat.0=result
  51.  
  52.  
  53. if jdat.1 < jdat.2 then do; old=1; latest=2; end
  54. else do; old=2; latest=1; end
  55.  
  56. dif=jdat.0-jdat.latest
  57.  
  58. if year.0=year.old then dif = jdat.0-jdat.latest
  59. else dif =8
  60.  
  61. if dif < saveInterval  then do; say 'dif= 'dif 'no save necessary'; exit; end
  62. else do; file.old=strip(file.old,'L'); say file.old; return; end
  63.  
  64.  
  65.  
  66. ElimDir:
  67. Signal on Error
  68. rc=RXQUEUE("Create", 'elimdirQ')
  69. rc=RXQUEUE("Set", 'elimdirQ')
  70. do queued()
  71.    pull
  72. end /* do */
  73.  
  74. arg deaddir .
  75.  
  76. rc=SysFileTree(deaddir'\*.*',dirs,'BS', '*****', '-----')
  77. do i=1 to dirs.0
  78. parse var dirs.i daye timee sizee atte filee
  79.    push atte filee;
  80. end /* do */
  81.  
  82. do Queued()
  83. pull atte filee;
  84. if pos('D', atte) = 2 then 'RD' filee
  85. else 'del' filee '/N'
  86. end /* do */
  87.  
  88. 'RD' DEADDIR
  89. RC=RXQUEUE('Delete', 'elimdirQ')
  90. return
  91.  
  92. error:
  93. say 'Errors have occured'
  94. do queued()
  95.    pull
  96. end /* do */
  97. if RXQUEUE('Delete', 'elimdirQ')=0 then say 'queue deleted'
  98. exit
  99.  
  100. Desks:
  101. Arg toDrive
  102. CALL getBOOT
  103.  
  104. call finddesk
  105.  
  106. /*if dialog then echo on*/
  107. DIR20or21=DESKTOP
  108. RC=SysFileTree(driveis'\'DIR20or21'\*.*', 'deskdirs', 'SDO')
  109.  
  110. xcopy driveis'\'DIR20or21'\*.* 'todrive'\dsk21sav\*.* /E/O >NUL'
  111. restore.0 ='%1\os2\Xcopy 'todrive'\DSK21SAV %1\'DIR20or21'\*.* /E'
  112. do  k=1 to deskdirs.0
  113. directorywithblanks='"'deskdirs.k'"'
  114. 'xcopy ' directorywithblanks todrive'\DK21'k'\*.* /E/O >NUL'
  115. restore.k='%1\os2\Xcopy DK21'k directorywithblanks'\*.* /E/O'
  116. end
  117.  
  118. "xcopy " driveis"\OS2\OS2*.INI" todrive '/t/h/o >NUL'
  119. "attrib" todrive"\*.ini -s -r"
  120.  
  121. "copy " driveis"\CONFIG.SYS" TODRIVE"\ORIGINAL.SYS" '>NUL'
  122.  
  123. call SysFileDelete todrive'\deskrstr.cmd'
  124. OUTFILE = TODRIVE'\DESKRSTR.CMD'
  125. call lineout outfile,'rem'
  126. call lineout outfile,'rem The format is:        deskrstr  c:'
  127. call lineout outfile,'rem    Where c: is the OS/2 Drive  to receive the following files:'
  128. call lineout outfile,'rem       \OS2\OS2.INI  -  \OS2\OS2SYS.INI - and the DESKTOP directory'
  129. call lineout outfile,'xcopy OS2.INI %1\OS2\OS2.INI /t/h/o'
  130. call lineout outfile,'xcopy OS2SYS.INI %1\OS2\OS2SYS.INI /t/h/o'
  131. call lineout outfile,restore.0
  132. do i = 1 to deskdirs.0
  133. call lineout outfile,restore.i
  134. end
  135. return
  136.  
  137. finddesk:
  138.  
  139. ctr=1
  140. app='FolderWorkareaRunningObjects'
  141. call sysIni 'SYSTEM', App,'ALL:', 'stem'
  142. do i=1 to stem.0
  143.        if pos("\DESKTOP",stem.i) > 0 | pos("\OS!",stem.i) >'0' then found.ctr=stem.i
  144. end
  145.  
  146. rc=SysFileTree(found.ctr,dirs,'D')
  147. do i=1 to dirs.0
  148. parse upper var dirs.i date time . . directory
  149. directory=strip(directory,'L')
  150. parse var directory driv'\' dname
  151. parse var dname first rest
  152. found.ctr=dname
  153. birthdate.ctr=date '-' time
  154. end  /* Do */
  155.  
  156. desktop=found.ctr; 
  157. return
  158.  
  159.  
  160.  
  161.  
  162. getBOOT:
  163. bootdrive = Value('Path',,'OS2ENVIRONMENT')
  164. parse upper var bootdrive bootdrive
  165. Driveis = Substr(bootdrive,Pos('\OS2\SYSTEM',bootdrive)-2,2)
  166. return
  167.  
  168. julian:
  169. arg cyear cmonth cday
  170. cmonth=strip(cmonth,'L',0)
  171. if cyear // 4=0 & cyear // 200 \=0 then leap=1
  172. else leap=0
  173. mo.1=0
  174. mo.2=31
  175. mo.3=59+leap
  176. mo.4=90+leap
  177. mo.5=120+leap
  178. mo.6=151+leap
  179. mo.7=181+leap
  180. mo.8=212+leap
  181. mo.9=243+leap
  182. mo.10=273+leap
  183. mo.11=304+leap
  184. mo.12=334+leap
  185. DofYr=mo.cmonth+cday
  186. if length(DofYr)=1 then dofyr='00'||dofyr
  187. else if length(DofYr)=2 then dofyr='0'||dofyr
  188.    else if length(DofYr)\=3 then do; say date error; exit; end
  189. jdate=right(cyear,2)||DofYr
  190. return jdate
  191.  
  192.