home *** CD-ROM | disk | FTP | other *** search
/ Amiga Computing 63 / ac063.adf / cinemorphjr.lha / SupportFiles / file_total.rexx next >
OS/2 REXX Batch file  |  1993-06-08  |  1KB  |  39 lines

  1. /*     >>> file_total.rexx <<<      *
  2.  * Get the sum of the sizes of the  *
  3.  * files in a directory using the   *
  4.  * AmigaDOS "list" command.         */
  5.  
  6. IF ~Exists(Arg(1)) THEN DO
  7.    SAY "ERROR in filetotal.rexx",
  8.        "- Directory does not exist"
  9.        RETURN 0
  10.    END
  11. dirname = '22'x || Arg(1) || '22'x
  12.  
  13. /* Temporary store for "list" */
  14. store = 'T:MY_VERY_UNIQUE_TEMPORARY_FILE'
  15.  
  16. doscom = 'list >'store dirname 'files nohead'
  17. ADDRESS COMMAND doscom
  18. succ = Open(file,store,'r')
  19. total = 0
  20. DO FOREVER WHILE ~Eof(file)
  21.   line = Reverse(Readln(file))
  22.  /* the following line assumes the standard
  23.  "list" command.  It is "safer" to read the
  24.  string backwards, as this allows for all
  25.  filename possibilities  */
  26.   PARSE VAR line time date flags size name
  27.   /* filter out non numbers */
  28.   IF ~Datatype(size,'Num') THEN size = 0
  29.   total = total + reverse(size)
  30. END
  31.  
  32. /* The following two lines are only needed for
  33.    "correctness", and may slow down the program;
  34.    if used, "delete" should be resident.     */
  35. /* succ = Close(file)             */
  36. /* ADDRESS COMMAND 'delete' store */
  37.  
  38. RETURN total
  39.