December 03, 2020, 08:20:32 PM

Author Topic: [bb] Hard Drive Cleaner by Oldefoxx [ 1+ years ago ]  (Read 477 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Hard Drive Cleaner by Oldefoxx [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Hard Drive Cleaner
Author : Oldefoxx
Posted : 1+ years ago

Description : Short and easily modifiable program that allows you to scan and delete empty directories, temporary internet files, all .TMP and .BAK files, cache files, contents of all TEMP and TMP directories, and if you like, you can add the code to delete cookies as well.  Some files and directories may be protected, so these will not delete, and on rerunning this program more than once, some parent directories may be flagged for possible deletion if all their subdirectories were deleted on a previous run.

Code :
Code: BlitzBasic
  1. Global swidth=800, sheight=600, v$
  2.  
  3. Graphics swidth,sheight,16
  4. ClsColor 0,0,128
  5. Cls
  6. AppTitle "HD Cleaner"
  7. Print"  Hard Drive Cleaner, by Donald R. Dardem, November 2002"
  8. Print""
  9. Print"  WARNING! Use this program with Caution!  If used or modified"
  10. Print"  incautiously, it may delete some essential file or directory"
  11. Print"  that is required for proper operation of your system."
  12. Print""
  13. Print"  No warrantee as to suitability or operation is given or implied,"
  14. Print"  so use at your own risk.  Note that some programs may use a zero-"
  15. Print"  length file as a flag of some sort, or there may be an empty"
  16. Print"  directory that is needed at certain other times for the proper"
  17. Print"  operation of some program.  That is the type of issue that would"
  18. Print"  become a problem if the needed file or directory is deleted."
  19. Print"  While this approach is rarely today, some programs have behaved"
  20. Print"  in this fashion in the past, and others may again in the future."
  21. Print""
  22. Print"  Note that when a question is asked, you must enter an answer that"
  23. Print"  includes the letter 'Y' (such as 'y', 'Y', 'yes' or 'okay') if"
  24. Print"  you want to signify 'yes', otherwize the question defaults to"
  25. Print"  'No' when the Enter key is pressed."
  26. Print""
  27. Print""
  28. d$=Input$("Automatically delete zero-byte (empty) files? ")
  29. killnull=Instr(Upper$(d$),"Y")
  30. d$=Input$("Automatically delete .TMP files? ")
  31. killtmp=Instr(Upper$(d$),"Y")
  32. d$=Input$("Automatically delete .BAK files? ")
  33. killbak=Instr(Upper$(d$),"Y")
  34. d$=Input$("Automatically delete Temporary Internet Files? ")
  35. killTIF=Instr(Upper$(d$),"Y")
  36. For a%=Asc("C") To Asc("Z")
  37.   d$=Chr$(a%)+":"+Chr$(0)
  38.   chkdrive=1
  39.   While d$>""
  40.     If c$>"" And chkdir=0 Then
  41.       Color 128,255,0
  42.       If Right$(c$,2)<>":" Then
  43.         Print c$
  44.         e$=Upper$(c$)
  45.         b%=Instr(e$,"CACHE")
  46.         If b%>0 And b%+6<Len(e$) And killTIF Then Goto erasedir
  47.         b%=Instr(e$,"TEMP")
  48.         If b%>0 And b%+5<Len(e$)And killtmp Then Goto erasedir
  49.         b%=Instr(e$,"TMP")
  50.         If b%>0 And b%+4<Len(e$)And killtmp Then Goto erasedir
  51.         b%=Instr(e$,"TEMPORARY INTERNET FILES")
  52.         If b% And b%+25<Len(e$) Then
  53. .erasedir
  54.           DeleteDir c$
  55.         Else
  56. .askerase
  57.           e$=Input$("The above directory is empty, delete it? ")
  58.           If Instr(Upper$(e$),"Y") Then DeleteDir c$
  59.         EndIf
  60.       EndIf
  61.     EndIf
  62.     b%=Instr(d$,Chr$(0))
  63.     If b%=0 Then b%=Len(d$)+1
  64.     c$=Left$(d$,b%-1)
  65.     chkdir=0
  66.     d$=Mid$(d$,b%+1)
  67.     If Right$(c$,1)<>"" Then c$=c$+""
  68.     b%=ReadDir(c$)    
  69.     While b%>0
  70.       f$=NextFile$(b%)
  71.       If f$="" Then Exit
  72.       If Left$(f$,1)<>"." Then
  73.         e$=c$+f$
  74.         chkdir=chkdir+1
  75.         If chkdrive Then
  76.           chkdrive=0
  77.           numdrives=numdrives+1
  78.         EndIf
  79.         If FileType(e$)=2 Then
  80.           d$=d$+e$+Chr$(0)
  81.           numdirs=numdirs+1
  82.         Else
  83.           Color 255,255,192
  84.           nb=FileSize(e$)
  85.           ue$=Upper$(e$)
  86.           If nb=0 Then
  87.             Color 255,128,0
  88.             nilfiles=nilfiles+1
  89.             If killnull Then DeleteFile e$
  90.           ElseIf Instr(ue$,"TEMPORARY INTERNET FILES") Or Instr(ue$,"CACHE")Then
  91.             Color 128,128,128
  92.             If killTIF Then DeleteFile e$
  93.           ElseIf Instr(ue$,"TMP") Or Instr(ue$,"TEMP")Then
  94.             Goto killtmps
  95.           Else    
  96.             Select Upper$(Right$(e$,4))
  97.             Case ".TMP"   ;tabulate temporary files
  98. .killtmps
  99.               Color 192,192,255
  100.               If killtmp Then
  101.                 DeleteFile e$
  102.               Else
  103.                 tmpfiles=tmpfiles+1
  104.                 tmpbyteslo=tmpbyteslo+nb
  105.                 While tmpbyteslo>100000000
  106.                   tmpbyteshi=tmpbyteshi+1
  107.                   tmpbyteslo=tmpbyteslo-100000000
  108.                 Wend
  109.               EndIf
  110.             Case ".BAK"    ;tabulate backup files
  111.               Color 160,255,160
  112.               If killbak Then
  113.                 DeleteFile e$
  114.               Else
  115.                 bakfiles=bakfiles+1
  116.                 bakbyteslo=bakbyteslo+nb
  117.                 While bakbyteslo>100000000
  118.                   bakbyteshi=bakbyteshi+1
  119.                   bakbyteslo=bakbyteslo-100000000
  120.                 Wend
  121.               EndIf
  122.             Case ",BB"    ;tabulate BlitzBASIC source files
  123.               bbfiles=bbfiles+1
  124.             Default
  125.             End Select  
  126.           End If
  127.           strnumb(0,nb)
  128.           g$=e$+String$(" ",swidth/8-Len(e$)-Len(v)-6)+v+" bytes"
  129.           Print g$
  130.           numfiles=numfiles+1
  131.           byteslo=byteslo+nb
  132.           While byteslo>100000000
  133.             byteslo=byteslo-100000000
  134.             byteshi=byteshi+1
  135.           Wend
  136.         EndIf
  137.       EndIf
  138.     Wend
  139.   Wend
  140. Next
  141. Print "Number of scanned drives: "+numdrives
  142. Print "Number of scanned directories: "+numdirs
  143. Print "Number of scanned files: "+numfiles
  144. strnumb(byteshi,byteslo)
  145. Print "Total bytes in files: "+v
  146. Print "Number of zero-byte files: "+nilfiles
  147. strnumb(tmpbyteshi,tmpbyteslo)
  148. Print "Number of .TMP files: "+tmpfiles+", Number of bytes: "+v
  149. strnumb(bakbyteshi,bakbyteslo)
  150. Print "Number of .BAK files: "+bakfiles+", Number of bytes: "+v
  151. Function strnumb(hi,lo)
  152. Local z$,w,zz$,x
  153. w=hi
  154. x=lo
  155. While x>100000000
  156.   w=w+1
  157.   x=x-100000000
  158. Wend
  159. zz=w
  160. z=x
  161. z=zz+String$("0",8-Len(z))+z
  162. w=Instr(z,".")
  163. If w=0 Then
  164.   w=Len(z)+1
  165. Else
  166.   x=Instr(z,"e")
  167.   If x Then
  168.     zz=Left$(z,x-1)
  169.     x=Mid$(z,x+1,Len(z)-x)
  170.     z=Left$(z,1)+Mid$(zz,3,Len(zz)-2)
  171.     z=z+String$("0",x-Len(z)+1)
  172.     w=Len(z)+1
  173. Print "w = "+w
  174.   Else
  175.     While Right$(z,1)="0"Or Right$(z,1)="."
  176.       z=Left$(z,Len(z)-1)
  177.     Wend
  178.   EndIf
  179. EndIf
  180. While w>3
  181.   w=w-3
  182.   z=Left$(z,w-1)+","+Mid$(z,w,Len(z)-w+1)
  183. Wend    
  184. While Left$(z,1)="0" Or Left$(z,1)=","
  185.   z=Mid$(z,2,Len(z)-1)
  186. Wend
  187. If z="" Then z="0"
  188. v=z
  189. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal