2007~2011/Windows Platform2010. 4. 14. 00:01

특정 폴더의 크기(Size)를 Text File 로 기록하는 스크립트를 아래와 같이 만들어 봤습니다.
필요할 때가 있겠죠? 없음 말..;;;


[스크립트]
아래 스크립트를 GetFolderSize.vbs 이름으로 저장해서 사용하면 되겠습니다.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\TEMP") '확인할 폴더 대상

strComputer = "."

Const ForReading =1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")

'로그가 저장될 경로와 파일명, 없으면 자동 생성 (ForAppending)
Set f = fso.OpenTextFile("D:\LaiGoScript\foldersize.txt",ForAppending, True)
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

f.writeLine objFolder.Size
f.Close



[실행결과]
연속해서 두 번 실행해 봤습니다. C:\Temp 공간이 12,649,754 byte 라는 것을 확인할 수 있습니다.





[참고자료]
Can I Use a Script to Determine the Size of a Folder on a Remote Computer?
http://blogs.technet.com/heyscriptingguy/archive/2004/11/18/can-i-use-a-script-to-determine-the-size-of-a-folder-on-a-remote-computer.aspx

Programming the FileSystemObject
http://msdn.microsoft.com/en-us/library/2z9ffy99(VS.85).aspx


작성자 : Lai Go / 작성일자 : 2010.04.22

Posted by Lai Go