home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / netutl1.zip / TDIR.CMD < prev   
OS/2 REXX Batch file  |  1995-01-03  |  3KB  |  55 lines

  1. /* A REXX program for printing a tree of directories  01/05/95 Ver 1.1  */
  2. /* Written by William M. Comegys II 76226,2747                          */
  3. /* Copywright 1995 William M. Comegys II                                */
  4. /*  Use a spread sheet parse command to break these apart               */
  5. /* This program totals up all files in each directory below the current */
  6. /* And out puts them to the screen or a redirection can be used  > or | */
  7. /*
  8.     Ascnum           String number in bytes for each file
  9.     Dirs             All directorys under the current
  10.     Dtemp            A Holding varable when formating each line of output
  11.     Dtotal           A varable which the number for each indvidule directory is formated and written to the display
  12.     Filebytes        File size in bytes for each file
  13.     Gtotal           Grand total for all files under this directory
  14.     Newfilespec      Appended to the directory is \*.*
  15.     t                Left over from older versions makes Dtotal into an array
  16.     Totaler          Acumulator for files in each directory
  17. */
  18.  
  19. /* trace(?I) */
  20.  
  21. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'         /* load extra functions */
  22. call SysLoadFuncs
  23. numeric digits(20)
  24. t = 0
  25. Gtotal = 0
  26. Totaler = 0
  27. C_dir = directory()
  28. call SysFileTree '*.*', 'Dirs', 'ODS'                              /* Get directories  */
  29.  
  30. do i=1 to Dirs.0                                         /* Loop to get files in each directory          */
  31.     newdir = directory(Dirs.i)
  32. /*    say newdir
  33.     "cd"   */
  34.     Newfilespec = "*.*"                                     /* Append \*.* to the directory             */
  35.     call sysfiletree Newfilespec, 'files', 'f'              /* Get individule files                     */
  36.     Totaler = 0                                              /* Set the Subdirectory size to 0           */
  37.  
  38.    do j=1 to files.0                                       /* Loop to add up individule file sizes       */
  39.         Ascnum = substr(Files.j, 18, 11)                          /* Add up the byte size for each file  */
  40.         Ascnum =  translate(Ascnum, "0", " " )                    /* Some messing around to convert the bytes size of a files to integer */
  41.         Filebytes = Ascnum * 1
  42.         Totaler=Totaler+Filebytes                                 /* Add up each files size in bytes   */
  43.    end /* do */
  44.  
  45.      Gtotal = Totaler + Gtotal                                    /* Add up total file size for all directory (not output) */
  46.      t = t + 1
  47.      Dtemp = Insert(Dirs.i, "-",,40,"-")                          /* Puts - expandes to a string length of 40           */
  48.      Totaler = format(Totaler, 13)                                /* Right justifies numbers        */
  49.      Dtotal.t = Insert(Totaler, Dtemp,50,,"-")                    /* Put what is output to the screen in an array */
  50.      say Dtotal.t format(files.0, 7)                              /* Outputs to the screen                 */
  51.  
  52. end /* do */
  53. C_dir = directory(C_dir)
  54. exit
  55.