Created
January 8, 2013 17:53
-
-
Save anonymous/4486092 to your computer and use it in GitHub Desktop.
Finds old files and folders, outputs to CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO: http://gallery.technet.microsoft.com/scriptcenter/Outputs-directory-size-964d07ff | |
http://gallery.technet.microsoft.com/scriptcenter/Delete-files-older-than-x-13b29c09 | |
http://gallery.technet.microsoft.com/scriptcenter/d81d620c-0d1b-4b7a-9c85-13660e929750 | |
http://www.tek-tips.com/viewthread.cfm?qid=1687849 | |
http://www.tek-tips.com/viewthread.cfm?qid=954944 | |
## VBS: | |
On Error Resume Next | |
folderPath = "C:\windows" | |
folderAge = 365 | |
folderSize = 1024*1024*200 | |
outputFileName = "OldLargeFolders.txt" | |
dim oFS, oFolder, objOutputFile | |
set oFS = WScript.CreateObject("Scripting.FileSystemObject") | |
set oFolder = oFS.GetFolder(folderPath) | |
Set objOutputFile = oFS.OpenTextFile(outputFileName, 2, True) | |
MsgBox "Searching "&folderPath&" and outputting to (and overriding) "&outputFileName&"..." | |
objOutputFile.WriteLine("Name,Size (>" & folderSize/1024/1024 & " MB),Modified (>" & folderAge & " days)") | |
WriteFolderDetails oFolder | |
MsgBox "Done searching "&folderPath | |
sub WriteFolderDetails(oF) | |
If DateDiff("d", oF.DateLastModified, Now) > folderAge Then | |
If oF.Size > folderSize Then | |
objOutputFile.WriteLine(oF & "," & Round(oF.Size/1024/1024) & "," & oF.DateLastModified) | |
End If | |
If Err.Number <> 0 Then | |
objOutputFile.WriteLine(oF & ",ERROR," & Err.Description) | |
Err.Clear | |
End If | |
End If | |
dim F | |
for each F in oF.Subfolders | |
WriteFolderDetails(F) | |
next | |
end sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment