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