Nightoholic.com
Doing College Online, Staying Up All Night to Research and Write! (Homework Assignments, Personal Notes, Research Papers, Random Images, etc.)
Database for all your documents, school assignments, or anything else that might be useful or entertaining. No registration required!


Find the largest files on your computer. Fix disk full errors.

Find the largest files on your computer. Fix disk full errors.

Here is how:
1.Boot into "Safe Mode with Networking".
2.Log on under an admin account.
3.Open this post.
4.Mark the code below, then press Ctrl+C to copy it. You need everything between "Code begins here" and "Code ends here", including these two lines.
5.Click Start, then type the three letters cmd into the Search box and press Enter.
6.Type this command and press Enter:
notepad dirr.vbs
(allow a new file to be created)
7.Press Ctrl+V to paste the code into this notepad.
8.Save the data, then close the file.
9.Type this command and press Enter:
cscript dirr.vbs c: 100000000
(a "1" followed by 8 zeros)
10.Wait until the program ends. It could take 10 minutes.
11.Type this command:
notepad "%temp%files.txt"
You can now see a sorted list of all files on drive C: that are > 100 MBytes. Have a close look at the bottom entries. Anything suspicioius, any big files you were not aware of?
'Code begins here
'--------------------------------------------------------
'Create a recursive directory listing sorted by file size
'5.11.2011 FNL
'--------------------------------------------------------
Dim aFileList, aLockList, iCount, iFileCount, iLockCount
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oWshShell = CreateObject("WScript.Shell")
sDir = oWshShell.ExpandEnvironmentStrings("%temp%Dir.txt")
sOut = oWshShell.ExpandEnvironmentStrings("%temp%Files.txt")
sBat = oWshShell.ExpandEnvironmentStrings("%temp%Batch.bat")
DQ = """"
iTotal = CLng(0) 'Total size of all files
iCutoff = -1 'Files less than this size won't be listed
sFolder = oWshShell.CurrentDirectory
ProcessParms
BuildDirectoryList
GetFilesizes
GenerateOutput
'-----------------------------------
'Process the command line parameters
'-----------------------------------
Sub ProcessParms
if wscript.Arguments.count = 0 then Exit Sub
if instr(wscript.Arguments(0), "?") > 0 then Error ""
sFolder = WScript.Arguments(0)
if not ofso.FolderExists(sFolder) then Error("Cannot locate the folder """ & sFolder & """")
If wscript.Arguments.count > 1 then iCutoff = CLng(WScript.Arguments(1))
End Sub
'---------------------------------------------------
'Build a directory list, using dir /s
'In order to cope with Umlaute etc, it is necessary
'to first change the code page, then execute the
'"dir" command.
'---------------------------------------------------
Sub BuildDirectoryList
WScript.Echo "Building a directory list"
Set oBatch = oFSO.CreateTextFile(sBat, True)
oBatch.WriteLine "@echo off"
oBatch.WriteLine "mode con cp select=1252"
oBatch.WriteLine "dir /s /b /a-d " & DQ & sFolder & DQ & ">" & DQ & sDir & DQ
oBatch.Close
oWshShell.Run DQ & sBat & DQ, 0, True
End Sub
'-----------------------------------------
'Get the size of each file found by dir /s
'-----------------------------------------
Sub GetFilesizes
Set oDir = oFSO.OpenTextFile(sDir, 1)
aDir = Split(oDir.ReadAll, VbCrLf)
ReDim aFileList(UBound(aDir))
ReDim aLockList(UBound(aDir))
oDir.Close

iCount = 0
iFileCount = 0
iLockCount = 0
On Error Resume Next
For Each sName In aDir
If Not LTrim(sName) = "" Then
iSize = oFSO.GetFile(sName).Size
If Err.number = 0 Then 'Protects against locked files or excessively long paths
iCount = iCount + 1
iTotal = iTotal + iSize
sLine = Right(Space(17) & Format(iSize), 17) & " " & sName
If iSize >= iCutoff Then
aFileList(iFileCount) = sLine
iFileCount = iFileCount + 1
End If
if iCount mod 5000 = 0 then WScript.Echo iCount & " files processed"
Else
aLockList(iLockCount) = sName
iLockCount = iLockCount + 1
Err.clear
End If
End If
Next
On Error Goto 0
End Sub
'--------------------------------------------
'Sort the files and put them into a text file
'--------------------------------------------
Sub GenerateOutput
sTemp = oWshShell.ExpandEnvironmentStrings("%temp%dirr1.tmp")
Set oTemp = oFSO.CreateTextFile(sTemp, True)
For i = 0 To iFileCount - 1
oTemp.WriteLine aFileList(i)
Next
oTemp.Close
Set oFiles = oFSO.CreateTextFile(sOut, True)
sLine = "File list for """ & sFolder & """"
oFiles.WriteLine sLine
oFiles.WriteLine String(Len(sLine), "-")
oFiles.Close

oWshShell.Run "cmd.exe /c type " & DQ & sTemp & DQ & " | sort >> " & DQ & sOut & DQ, 0, True
Set oFiles = oFSO.OpenTextFile(sOut, 8)
oFiles.Writeline String(50, "-")
oFiles.Writeline Format(iCount) & " File(s) " & Format(iTotal) & " bytes"

If iLockCount > 0 Then
oFiles.WriteLine
oFiles.WriteLine "The following files could not be accessed:"
For i = 0 To iLockCount - 1
oFiles.WriteLine aLockList(i)
Next
End If
If iCutoff > -1 Then
oFiles.WriteLine
oFiles.WriteLine "Files < " & Format(iCutoff) & " bytes are counted but not listed"
End If
oFiles.Close
oWshShell.Run "notepad.exe " & DQ & sOut & DQ, 1, 0

WScript.Echo "The sorted list of " & Format(iCount) & " files is available in " & sOut
End Sub
'-----------------------------
'Insert dividers into a number
'-----------------------------
Function Format(iNumber)
Format = FormatNumber(iNumber, 0, -1, 0, True)
End Function
'----------------
'Error processing
'----------------
Sub Error(sMsg)
WScript.Echo "Usage: Dirr [Foldername] [Cutoff in bytes]"
If sMsg <> "" Then
WScript.Echo
WScript.Echo sMsg
End If
WScript.Quit
End Sub
'Code ends here

.......