home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / text / FAQ / bonus / faq_setdate_byKL.rexx < prev    next >
OS/2 REXX Batch file  |  1995-10-07  |  2KB  |  88 lines

  1. /*  ARexx script
  2.     for :Pearls/text/FAQ on CD "Meeting Pearls III"
  3.     - setting date with date keyword
  4.     - renaming to archive name keyword
  5.     $VER: faq_setdate_byKL.rexx 0.3 (18.09.95) ©1995 Khamsonh Marcel Khounlivong
  6.     */
  7.  
  8. OPTIONS RESULTS
  9.  
  10. PARSE ARG keylist destination
  11.  
  12. keylist     = Strip(keylist)
  13. destination = Strip(Strip(destination),t,'/') || '/'
  14. dates       = "Date:"
  15. string      = ""
  16. months      = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
  17. days        = "Mon Tue Wed Thu Fri Sat Sun"
  18.  
  19. IF (destination == "/") THEN DO
  20.     SAY "faq_setdate_byKL.rexx ©1995 Khamsonh Marcel Khounlivong"
  21.     SAY "use: [rx] faq_setdate_byKL[.rexx] keylist destination"
  22.     EXIT 0
  23.     END
  24.  
  25. CALL AddLib("rexxsupport.library",5,-30)
  26.  
  27. IF (~Open(infile,keylist,r)) THEN DO
  28.     SAY ''keylist 'not exists'
  29.     EXIT 20
  30.     END
  31.  
  32. DO FOREVER
  33.     line = ReadLn(infile)
  34.     IF (line == "") THEN DO
  35.         CALL Close(infile)
  36.         EXIT
  37.         END
  38.  
  39.     arcname = destination || Word(line,1)
  40.  
  41.     IF (~Open(file,arcname,r)) THEN DO
  42.         SAY ''arcname "can't open"
  43.         EXIT 20
  44.         END
  45.  
  46.     date = ""
  47.     CALL scan_word
  48.     CALL scan_word
  49.     CALL Close(file)
  50.  
  51.     IF (date == "") THEN DO
  52.         SAY ''arcname "missing date"
  53.         EXIT 20
  54.         END
  55.  
  56.     CALL set_date
  57.     END
  58.  
  59. scan_word:
  60.     DO UNTIL (string ~= "")
  61.         string = ReadLn(file)
  62.         END
  63.     DO WHILE (string ~= "")
  64.         string = Translate(string,' ','09'x)
  65.         IF (date ~= "") THEN LEAVE
  66.         IF (Find(dates, Strip(Word(string,1))) ~= 0) THEN
  67.             date = SubStr(string,WordIndex(string,2))
  68.         string = ReadLn(file)
  69.         END
  70.     RETURN
  71.  
  72. /*  setting date by overwriting download time with
  73.     header informations */
  74. set_date:
  75.     /*  there's a format starting with weekday */
  76.     IF (Find(days,Strip(Word(date,1),,',')) ~= 0) THEN
  77.         date = SubStr(date, WordIndex(date,2))
  78.  
  79.     day   = Word(date,1)
  80.     month = Right(Find(months,Word(date,2)),2,'0')
  81.     year  = Right(Word(date,3),2)
  82.     our   = Word(date,4)
  83.     newdate = day || '-' || month || '-' || year our
  84.  
  85.     ADDRESS command 'setdate' arcname newdate
  86.     IF (RC ~= 0) THEN EXIT 20
  87.     RETURN
  88.