Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for filesize.cmd

(view source code of filesize.cmd as plain text)

  1. /* FileSize,  Version 1.00                                         */
  2. /* Cloned from the Norton Utilities for DOS                        */
  3. /* Check total file size, space used and slack for specified files */
  4. /* Copyrights (C) 1999, Rob van der Woude                          */
  5.  
  6. /* Initialize RexxUtil */
  7. if RxFuncQuery( "SysLoadFuncs" ) <> 0 then do
  8. 	call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  9. 	call SysLoadFuncs
  10. end
  11.  
  12. /* Initialize  Quercus System's RexxLib */
  13. if RxFuncQuery( "RexxLibRegister" ) <> 0 then do
  14. 	call RxFuncAdd "RexxLibRegister", "rexxlib", "RexxLibRegister"
  15. 	call RexxLibRegister
  16. end
  17.  
  18. parse upper arg files destdrive"/"options
  19. if options = "?" then call syntax
  20. destdrive = strip( destdrive )
  21. S         = ""
  22. if left( options, 1 ) = "S" then S = "S"
  23. if files  = "" then files = "*"
  24. call SysFileTree files, "dummy.", "BO"
  25. if dummy.0 > 0 then do
  26. 	srcdrive  = filespec( "D", dummy.1 )
  27. end
  28. else do
  29. 	curdir = directory( )
  30. 	newdir = directory( files )
  31. 	srcdrive  = filespec( "D", newdir||".\" )
  32. 	newdir = directory( curdir )
  33. end
  34. srcclust  = dosdisk( "S", srcdrive ) * 512
  35. if destdrive <> "" then do
  36. 	if length( destdrive ) <> 2 then call syntax
  37. 	if substr( destdrive, 2, 1 ) <> ":" then call syntax
  38. 	drvletter = substr( destdrive, 1, 1 )
  39. 	if drvletter < "A" then call syntax
  40. 	if drvletter > "Z" then call syntax
  41. 	destclust = dosdisk( "S", drvletter||":" ) * 512
  42. end
  43.  
  44. call SysFileTree files, "files.", "F"||S
  45. totalsize  = 0
  46. totalspace = 0
  47. desttotal  = 0
  48. slack      = 0
  49. _files     = files.0
  50. if files.0 > 0 then do i = 1 to files.0
  51. 	parse value files.i with fdate ftime fsize and_the_rest
  52. 	totalsize  = totalsize + fsize
  53. 	totalspace = totalspace + fsize
  54. 	desttotal  = desttotal + fsize
  55. 	if totalsize // srcclust > 0 then do
  56. 		totalspace = ( totalspace % srcclust + 1 ) * srcclust
  57. 	end
  58. 	if destdrive <> "" then do
  59. 		if desttotal // destclust > 0 then do
  60. 			desttotal = ( desttotal % destclust + 1 ) * destclust
  61. 		end
  62. 	end
  63. 	slack = format( 100 - ( 100 * totalsize / totalspace ), 2, 1 )
  64. end
  65. say
  66. say " "||files
  67. numfilemsg = " "||_files||" file"
  68. if _files <> 1 then numfilemsg = numfilemsg||"s"
  69. say numfilemsg
  70. say " Total file size is  "||totalsize||" bytes"
  71. say " Total space used is "||totalspace||" bytes"
  72. say " "||slack||"% slack"
  73.  
  74. if destdrive <> "" then do
  75. 	drvinfo = SysDriveInfo( drvletter )
  76. 	freespace = word( drvinfo, 2 )
  77. 	drivesize = word( drvinfo, 3 )
  78. 	say
  79. 	say " "||drivesize||" bytes total on drive "||drvletter||":"
  80. 	say " "||freespace||" bytes free on drive "||drvletter||":"
  81. 	say " "||desttotal||" free bytes needed on drive "||drvletter||":"
  82. 	if freespace < totalspace then do
  83. 		say " Insufficient free space on drive "||drvletter||":"
  84. 	end
  85. 	else do
  86. 		say " Sufficient free space on drive "||drvletter||":"
  87. 	end
  88. end
  89. exit
  90.  
  91. syntax:
  92. 	say
  93. 	say " FileSize,  Version 1.00"
  94. 	say
  95. 	say " Usage:  FILESIZE [ filespec [ target_drive ] ]  [ /S ]"
  96. 	exit
  97. return
  98.  

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