Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for freespace.rex

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

  1. /* Display blank line */
  2. say
  3.  
  4. /* Check for command line parameter (none required) */
  5. parse arg params
  6. if params <> "" then call Syntax
  7.  
  8. /* Initialize RexxUtil library */
  9. if RxFuncAdd( 'sysloadfuncs', 'RexxUtil', 'sysloadfuncs' ) = 0 then do
  10. 	call sysloadfuncs
  11. end
  12. else do
  13. 	call Syntax "RexxUtil"
  14. end
  15.  
  16. /* Retrieve list of local drives */
  17. drives = SysDriveMap( "C:", "LOCAL" )
  18.  
  19. /* Check file system type of each drive */
  20. chkdrv.0 = 0
  21. do until drives = ""
  22. 	parse value drives with drive drives
  23. 	drvtype = SysFileSystemType( drive )
  24. 	if ( drvtype <> "" & drvtype <> "CDFS" ) then do
  25. 		j              = chkdrv.0 + 1
  26. 		parse value SysDriveInfo( drive ) with chkdrv.name.j chkdrv.free.j chkdrv.total.j .
  27. 		/* Srip trailing backslash */
  28. 		chkdrv.name.j  = " "||strip( chkdrv.name.j, "T", "\" )
  29. 		/* Calculate free space as a percentage of total space */
  30. 		chkdrv.perc.j  = ( ( 100 * chkdrv.free.j / chkdrv.total.j ) + 0.5 ) % 1
  31. 		/* Convert KB to GB */
  32. 		chkdrv.free.j  = ( ( chkdrv.free.j  / ( 1024 ** 2 ) ) + 0.5 ) % 1
  33. 		chkdrv.total.j = ( ( chkdrv.total.j / ( 1024 ** 2 ) ) + 0.5 ) % 1
  34. 		/* Increment array index by 1 */
  35. 		chkdrv.0       = j
  36. 	end
  37. end
  38.  
  39. /* Display header */
  40. say "Drive:     Size:      Free:      % Free:"
  41. say "======     =====      =====      ======="
  42.  
  43. /* Format screen output */
  44. do i = 1 to chkdrv.0
  45. 	say left(  chkdrv.name.i,   6, " " )||,
  46. 	    right( chkdrv.total.i, 10, " " )||,
  47. 	    right( chkdrv.free.i,  11, " " )||,
  48. 	    right( chkdrv.perc.i,  13, " " )
  49. end
  50.  
  51. /* Done */
  52. EXIT 0
  53.  
  54.  
  55. Syntax:
  56. 	errcode = 0
  57. 	parse arg errtype
  58. 	if errtype = "RexxUtil" then do
  59. 		errcode = 255
  60. 		say "Error: RexxUtil could not be loaded"
  61. 		say
  62. 	end
  63. 	say "FreeSpace.rex,  Version 1.00"
  64. 	say "Display size and free space for each local drive of the local computer"
  65. 	say
  66. 	say "Usage:    <REXX>  FreeSpace.rex"
  67. 	say
  68. 	say 'Where:    "<REXX>" is your Rexx interpreter:'
  69. 	say "                   - Windows:  REGINA.EXE with RexxUtil installed"
  70. 	say "                               (RexxUtil is not compatible with REXX.EXE)"
  71. 	say "                   - OS/2:     no need to specify, just rename script to *.cmd"
  72. 	say
  73. 	say "Returns:  On screen table with sizes and free space in GBs"
  74. 	say
  75. 	say "Written by Rob van der Woude"
  76. 	say "http://www.robvanderwoude.com"
  77. 	EXIT errcode
  78. return
  79.  

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