[스크립트] 지정폴더아래의 가장큰폴더용량 조사하기

이 스크립트는 vbs로서 prompt로 물어올때 조사하고자하는 경로를 입력해주면
그 아래의 폴더들의 사이즈를 조사해서 엑셀파일로 컨버트해서 report해줍니다.
조사하는데 시간이 약간 걸리니 감안을 하셔야할것 같습니다.
드라이브용량이 이상스럽게 많이 차지할때
도대체 어떤 폴더가 범인인지 알고자할때 유용한듯합니다.

출력물은 엑셀파일인데 가장 큰 사이즈의 폴더로부터 리스팅된답니다…


[#M_ 스크립트 보기 |스크립트 감추기 |스크립트 감추기 ‘ more=’ 스크립트 보기 ‘>
‘—————————————————————————————

‘ Name: getfoldersize.vbs
‘ Version: 1.0
‘ Date: 7-5-2002
‘ Author: Hans van der Zaag
‘ Description: getfoldersize.vbs calculates the size of all subfolders within
‘ a folder and sorts this data in an excel workbook

‘—————————————————————————————


rootfolder = Inputbox(“Enter directory/foldername: ” & _
chr(10) & chr(10) & “(i.e. C:Program Files or ” & _
“ServernameC$Program Files)” & chr(10) & chr(10), _
“Getfoldersize”, “C:Program Files”)

outputfile = “c:foldersize_” & Day(now) & Month(now) & Year(now) & “.xls”

Set fso = CreateObject(“scripting.filesystemobject”)
if fso.fileexists(outputfile) then fso.deletefile(outputfile)



‘Create Excel workbook
set objXL = CreateObject( “Excel.Application” )
objXL.Visible = False
objXL.WorkBooks.Add


‘Counter 1 for writing in cell A1 within the excel workbook
icount = 1

‘Run checkfolder
CheckFolder (FSO.getfolder(rootfolder))



Sub CheckFolder(objCurrentFolder)

For Each objFolder In objCurrentFolder.SubFolders
FolderSize = objFolder.Size
Tmp = (FormatNumber(FolderSize, 0, , , 0)/1024)/1024
ObjXL.ActiveSheet.Cells(icount,1).Value = objFolder.Path
ObjXL.ActiveSheet.Cells(icount,2).Value = Tmp
‘Wscript.Echo Tmp & ” ” & objFolder.Path
‘raise counter with 1 for a new row in excel
icount = icount + 1
Next

‘Recurse through all of the folders
For Each objNewFolder In objCurrentFolder.subFolders
CheckFolder objNewFolder
Next

End Sub


‘sort data in excel
objXL.ActiveCell.CurrentRegion.Select
objXL.Selection.Sort objXL.Worksheets(1).Range(“B1”), _
2, _
, _
, _
, _
, _
, _
0, _
1, _
False, _
1

‘Lay out for Excel workbook
objXL.Range(“A1”).Select
objXL.Selection.EntireRow.Insert
objXL.Selection.EntireRow.Insert
objXL.Selection.EntireRow.Insert
objXL.Selection.EntireRow.Insert
objXL.Selection.EntireRow.Insert

objXL.Columns(1).ColumnWidth = 60
objXL.Columns(2).ColumnWidth = 15
objXL.Columns(2).NumberFormat = “#,##0.0”
objXL.Range(“B1:B1”).NumberFormat = “d-m-yyyy”
objXL.Range(“A1:B5”).Select
objXL.Selection.Font.Bold = True
objXL.Range(“A1:B3”).Select
objXL.Selection.Font.ColorIndex = 5
objXL.Range(“A1:A1”).Select
objXL.Selection.Font.Italic = True
objXL.Selection.Font.Size = 16
ObjXL.ActiveSheet.Cells(1,1).Value = “Survey FolderSize ”
ObjXL.ActiveSheet.Cells(1,2).Value = Day(now) & “-” & Month(now) & “-“& Year(now)
ObjXL.ActiveSheet.Cells(3,1).Value = UCase(rootfolder)
ObjXL.ActiveSheet.Cells(5,1).Value = “Folder”
ObjXL.ActiveSheet.Cells(5,2).Value = “Total (MB)”


‘Finally close the workbook
ObjXL.ActiveWorkbook.SaveAs(outputfile)
ObjXL.Application.Quit
Set ObjXL = Nothing

‘Message when finished
Set WshShell = CreateObject(“WScript.Shell”)
Finished = Msgbox (“Script executed successfully, results can be found in ” & Chr(10) _
& outputfile & “.” & Chr(10) & Chr(10) _
& “Do you want to view the results now?”, 65, “Script executed successfully!”)
if Finished = 1 then WshShell.Run “excel ” & outputfile_M#]
스크립트 다운받기 379546.vbs

3 thoughts on “[스크립트] 지정폴더아래의 가장큰폴더용량 조사하기

  1. Pingback: 록시의 아지트

답글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다.