home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / dirutil / du.bas < prev    next >
BASIC Source File  |  1994-03-04  |  5KB  |  148 lines

  1. 1   ' DU - Disk Usage by Directory
  2. 2   '
  3. 3   ' Roy Stehle
  4. 4   '      SRI International, 333 Ravenswood, Menlo Park, CA 94025
  5. 5   '
  6. 6   '      31 December 1985
  7. 7   '
  8. 8   PRINT:PRINT:PRINT "       DU.BAS   --   Disk Usage by Directory"
  9. 9   PRINT
  10. 10  S=4096   ' Make S=1024 if run on floppy rather than hard disk
  11. 20  GOTO 8999   ' Are instructions desired?
  12. 30  OPEN "\du$$.dat" FOR OUTPUT AS 3
  13. 40  CLOSE 3
  14. 50  OPEN "\DU.LOG" FOR OUTPUT AS 3
  15. 60  C$="tree>\du$$.dat"
  16. 70  GOSUB 5000
  17. 100 OPEN "\DU$$.DAT" FOR INPUT AS 1
  18. 110 TB=TE=TF=0
  19. 120 D$="\"
  20. 130 PRINT : PRINT "Data logged in file \DU.LOG" 
  21. 140 P1$="  File      Disk      #  Eff.    Directory"
  22. 150 PRINT #3,P1$ : PRINT #3," "
  23. 160 PRINT : PRINT P1$ : PRINT
  24. 180 GOTO 310
  25. 200 INPUT #1,F$
  26. 210 IF EOF(1) GOTO 580
  27. 220 REM MOD BY GILLMANN NEXT 5 LINES
  28. 230 L=LEN(F$)
  29. 232 IF L<6 THEN 200
  30. 234 IF LEFT$(F$,1) = "P" THEN 240
  31. 236 F$=RIGHT$(F$,L-1)
  32. 238 GOTO 230
  33. 240 IF LEFT$(F$,2) <> "Pa" THEN GOTO 200
  34. 300 D$=RIGHT$(F$,L-6)
  35. 310 C$="dir "+D$+">\du_file.dat"
  36. 320 GOSUB 5000
  37. 400 OPEN "\DU_FILE.DAT" FOR INPUT AS 2
  38. 410 B=0 : E=S : F=0   ' byte count, disk space, file count
  39. 420 FOR I=1 TO 4:INPUT #2,S$:NEXT I
  40. 430 INPUT #2,S$
  41. 440 IF EOF(1) THEN GOTO 520
  42. 450 IF MID$(S$,14,1)="<" THEN GOTO 430
  43. 460 IF RIGHT$(S$,1)="e" THEN GOTO 520
  44. 470 V=VAL(MID$(S$,14,8))
  45. 480 B=V+B : F=F+1
  46. 490 E=(INT((V-1)/S)+1)*S+E
  47. 500 ' PRINT #3, B,T,S$
  48. 510 GOTO 430
  49. 520 CLOSE 2
  50. 530 P2$="########  ######## ##### ###    "
  51. 540 PRINT #3, USING P2$;B,E,F,100*B/E; : PRINT #3, D$
  52. 550 PRINT USING P2$;B,E,F,100*B/E; : PRINT D$
  53. 560 TB=TB+B : TE=TE+E : TF=TF+F
  54. 570 GOTO 200
  55. 580 '
  56. 590 P$="\                      \ ########"
  57. 600 PRINT : PRINT #3," "
  58. 610 PRINT #3, USING P$;"Total User Files:",TF
  59. 620 PRINT USING P$;"Total User Files:",TF
  60. 630 PRINT #3, USING P$;"Bytes in Files: ",TB
  61. 640 PRINT USING P$;"Bytes in Files: ",TB
  62. 650 PRINT #3, USING P$;"Disk Allocation Bytes: ",TE
  63. 660 PRINT USING P$;"Disk Allocation Bytes: ",TE
  64. 670 PRINT #3, USING P$;"Disk Efficiency (%): ",100*TB/TE
  65. 680 PRINT USING P$;"Disk Efficiency (%): ",100*TB/TE
  66. 690 PRINT #3," "
  67. 700 PRINT
  68. 710 CLOSE 1 : CLOSE 2 : CLOSE 3
  69. 720 C$="del \du$$.dat"
  70. 730 GOSUB 5000
  71. 740 C$="del \du_file.dat"
  72. 750 GOSUB 5000
  73. 999 END
  74. 4999 ' Subroutine to execute DOS commands by Andrew Folkins
  75. 5000 DEF SEG
  76. 5010 LOW = PEEK(&H30) : HI = PEEK(&H31)
  77. 5020 SHELL C$   ' execute the DOS command
  78. 5030 POKE &H30, LOW : POKE &H31, HI
  79. 5040 RETURN
  80. 8999 ' Routine to print instructions about program
  81. 9000 PRINT "Do you wish instructions (Y or N)?  ";
  82. 9010 K$=INKEY$ : IF K$="" THEN 9010
  83. 9020 IF K$="N" OR K$="n" THEN 30
  84. 9030 T$=CHR$(9)
  85. 9040 PRINT
  86. 9050 PRINT T$+"This program lists the number of bytes occupied by each "
  87. 9060 PRINT T$+"directory on the default disk.  For each directory, it
  88. 9070 PRINT T$+"indicates:"
  89. 9080 PRINT
  90. 9090 PRINT T$+"     The actual number of bytes in files"
  91. 9100 PRINT T$+"     The number of bytes in sectors to contain those files"
  92. 9110 PRINT T$+"     The number of files"
  93. 9120 PRINT T$+"     The storage efficiency."
  94. 9130 PRINT
  95. 9140 PRINT T$+"The program prints this information on the screen as it"
  96. 9150 PRINT T$+"is running.  It also writes the data to the file \DU.LOG."
  97. 9160 PRINT T$+"Two scratch files (\DU$$.DAT and \DU_FILE.DAT) are"
  98. 9170 PRINT T$+"created and deleted."
  99. 9180 PRINT
  100. 9190 PRINT T$+"If this program is run on a floppy disk, change statement 10"
  101. 9200 PRINT T$+"to S=1024 to reflect the smaller sector size of the floppy."
  102. 9210 PRINT
  103. 9220 PRINT T$+"This program does not know about hidden files because it"
  104. 9230 PRINT T$+"relies on the DOS DIRectory command for its information."
  105. 9240 PRINT T$+"It has been tested with BASICA under DOS 2.11."
  106. 9250 PRINT
  107. 9260 PRINT
  108. 9270 PRINT "Type any character to display a sample printout  ";
  109. 9280 K$=INKEY$ : IF K$="" THEN 9280
  110. 9290 PRINT
  111. 9300 PRINT
  112. 9310 PRINT T$+"  File      Disk      #  Eff.    Directory"
  113. 9320 PRINT
  114. 9330 PRINT T$+" 1485053   1871872   158  79    \"
  115. 9340 PRINT T$+"   39606    245760    59  16    \CMTTOOLS"
  116. 9350 PRINT T$+" 1476667   1552384    32  95    \CAD"
  117. 9360 PRINT T$+"  341993    458752    51  75    \CAD\PMS"
  118. 9370 PRINT T$+"   58937    110592    23  53    \CAD\GRAPE"
  119. 9380 PRINT T$+" 1172528   1527808   177  77    \CAD\COMMTECH"
  120. 9390 PRINT T$+"    5802     16384     2  35    \PROMO"
  121. 9400 PRINT T$+"  124646    208896    33  60    \BASIC"
  122. 9410 PRINT T$+"   11504     32768     7  35    \MODEL100"
  123. 9420 PRINT T$+"  706980    806912    41  88    \GPCC"
  124. 9430 PRINT T$+" 1078269   1187840    50  91    \FORTRAN"
  125. 9440 PRINT T$+"  766592    790528    11  97    \CMTBOXES"
  126. 9450 PRINT T$+"    2715      8192     1  33    \MISC"
  127. 9460 PRINT T$+"   41600     49152     2  85    \GAMES"
  128. 9470 PRINT T$+"   72035    147456    29  49    \BAND"
  129. 9480 PRINT
  130. 9490 PRINT T$+"Total User Files:             676"
  131. 9500 PRINT T$+"Bytes in Files:           7384927"
  132. 9510 PRINT T$+"Sector Bytes Used:        9015294"
  133. 9520 PRINT T$+"Disk Efficiency (%):           82"
  134. 9530 PRINT
  135. 9540 PRINT "Type any character to continue the instructions  ";
  136. 9550 K$=INKEY$ : IF K$="" THEN 9550
  137. 9560 PRINT
  138. 9570 PRINT : PRINT : PRINT : PRINT
  139. 9580 PRINT T$+"If you do not need these instructions, you may"
  140. 9590 PRINT T$+"delete lines 9000 thru 9700."
  141. 9600 PRINT
  142. 9610 PRINT
  143. 9620 PRINT "Do you wish to Run the program (Y OR N)?  ";
  144. 9630 K$=INKEY$ : IF K$="" THEN 9630
  145. 9640 IF K$="Y" OR K$="Y" THEN GOTO 30
  146. 9700 GOTO 999
  147. 9999 GOTO 30
  148.