home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / RSCOPY.ZIP / RSCOPY.CMD next >
OS/2 REXX Batch file  |  1992-11-14  |  2KB  |  69 lines

  1. /* Do intelligent copy if source newer than target, or target doesn't exist */
  2.  
  3. call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
  4.  
  5. s_file.=0
  6. t_file.=0
  7.  
  8. parse arg source
  9. parse var source source target
  10. target = strip(target)
  11. source = strip(source)
  12.  
  13. if target = "" then do
  14.     say 'No target specified!'
  15.     return -1
  16. end  /* Do */
  17.  
  18. if source = "" then do
  19.     say 'No source specified!'
  20.     return -1
  21. end  /* Do */
  22.  
  23. rc = SysFileTree(source, 's_file', 'TF')
  24. if rc then do say 'No SOURCE file'
  25.     return -1
  26.     end  /* Do */
  27.  
  28. if s_file.0 = 0 then do
  29.     say 'No source files for' source
  30.     return 0
  31.     end  /* Do */
  32.  
  33. say 'Checking' s_file.0 'file(s) in' source
  34. copied = 0
  35.  
  36. do i = 1 to s_file.0
  37.     parse var s_file.i s_time size attrib s_name
  38.     s_time = translate(s_time,'','/',x2c('00'x))
  39.     if right(target,1) \= '\' then
  40.         target = target||'\'
  41.     t_name = FileSpec(drive,target)||FileSpec(path,target)||FileSpec(name,s_name)
  42.     rc = SysFileTree(t_name, 't_file', 'TF')
  43.     if t_file.0 = 0 then do
  44.         say '--' t_name 'NOT THERE so copying'
  45.         '@copy' s_name t_name '>nul'
  46.         copied = copied + 1
  47.         end  /* Do */
  48.     else do
  49.         parse var t_file.1 t_time rest
  50.         t_time = translate(t_time,'','/',x2c('00'x))
  51.         if s_time > t_time then do
  52.             say '  older target so Copying' s_name 'to' target
  53.             '@copy' s_name t_name '>nul'
  54.             copied = copied + 1
  55.             end  /* Do */
  56.         end  /* Do */
  57. end /* do */
  58.  
  59. if copied \= 0 then do
  60.     say copied 'file(s) copied to' target
  61.     say
  62.     end
  63. else do
  64.     say '*** NO FILES COPIED ***'
  65.     say
  66.     end
  67.  
  68. return 0
  69.