Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for diskuse.rex

(view source code of diskuse.rex as plain text)

  1. /* DiskUse.cmd, Version 4.00 for OS/2 and Regina Rexx  */
  2. /* Display diskspace used by subdirectories            */
  3. /* Written by Rob van der Woude                        */
  4. /* http://www.robvanderwoude.com                       */
  5.  
  6.  
  7. /* Initialize RexxUtil */
  8. Call RxFuncAdd "sysloadfuncs", "RexxUtil", "sysloadfuncs"
  9. Call sysloadfuncs
  10.  
  11. /* Initialize RexxLib */
  12. If RxFuncQuery( "RexxLibRegister" ) <> 0 Then Do
  13. 	If RxFuncAdd( "RexxLibRegister", "RexxLib", "RexxLibRegister" ) = 0 Then Call RexxLibRegister
  14. End
  15.  
  16. /* Command line parsing */
  17. Parse Upper Arg startdir
  18. If Pos( "?", startdir ) > 0 Then Call Syntax
  19. Select
  20. 	When startdir = "" Then fdir = directory( )
  21. 	When startdir = "." Then fdir = directory( )
  22. 	When startdir = ".." Then fdir = directory( ".\..\." )
  23. 	Otherwise Do
  24. 		Call SysFileTree startdir, "exist.", "DO"
  25. 		If exist.0 <> 1 Then Do
  26. 			Call Syntax "Specified startdir not found: "||startdir
  27. 		End
  28. 		fdir = exist.1
  29. 	End
  30. End
  31. fdir  = Strip( fdir, "T", "\" )
  32. fdlen = Length( fdir ) + 1
  33.  
  34. /* Display total file size for start directory */
  35. Call SysFileTree fdir||"\*", "files.", "F"
  36. totalsize = 0
  37. If files.0 > 0 Then Do j = 1 to files.0
  38. 	Parse Value files.j With . . fsize . files.j
  39. 	files.j = Strip( files.j )
  40. 	totalsize = totalsize + fsize
  41. End
  42. Say ".\="||totalsize
  43.  
  44. /* Display total file size for all subdirectories */
  45. Call SysFileTree fdir||"\*", "fdirs.", "DO"
  46. If fdirs.0 > 0 Then Do
  47. 	If RxFuncQuery( "ArraySort" ) = 0 Then Call ArraySort "fdirs."
  48. 	Do i = 1 To fdirs.0
  49. 		Call SysFileTree fdirs.i||"\*", "files.", "FS"
  50. 		totalsize = 0
  51. 		If files.0 > 0 Then Do j = 1 to files.0
  52. 			Parse Value files.j With . . fsize . files.j
  53. 			files.j = Strip( files.j )
  54. 			totalsize = totalsize + fsize
  55. 		End
  56. 		Say SubStr( fdirs.i, fdlen + 1 )||"="||totalsize
  57. 	End
  58. End
  59. Exit 0
  60.  
  61.  
  62. Syntax:
  63. 	msg = Arg( 1 )
  64. 	If msg <> "" Then Do
  65. 		Say
  66. 		Say msg
  67. 	End
  68. 	Say
  69. 	Say "DiskUse, Version 4.00 for OS/2 and Regina Rexx"
  70. 	Say "Display diskspace used by current directory and subdirectories"
  71. 	Say
  72. 	Say "Usage:  DISKUSE  [ startdir ]"
  73. 	Say
  74. 	Say "Will use Quercus System's RexxLib if available to sort the listing"
  75. 	Say
  76. 	Say "Written by Rob van der Woude"
  77. 	Say "http://www.robvanderwoude.com"
  78. 	Exit 1
  79. Return
  80.  

page last modified: 2024-04-16; loaded in 0.0255 seconds