Re: Jak napisać skrypt

Autor: Michal Biek <mbiek_at_2.pl>
Data: Thu 21 Jan 2010 - 20:35:09 MET
Message-ID: <hjaaj3$1r76$1@opal.icpnet.pl>
Content-Type: text/plain; format=flowed; charset="iso-8859-2"; reply-type=original

ab log(in):
> Potrzebuję regularnie sprawdzić wielkość zajmowaną przez 10
> folderów. [...]

:-) Może pomoże vbscript'k pex. jn.:

Warunek: Te Twoje 10 (sub)folderów powinno znajdować się w jednym
folderze.
Inaczej trzeba napisać trochę inszy vbscript albo js albo itd. :-)

FolderSize.vbs
--------------------
Set FSO = CreateObject("Scripting.FileSystemObject")
title = "Rozmiar folderu by VBscript_MB ;-)"
totalsize = 0
megaconv = (1024*1024)
defaultfoldertosearch = "C:\Windows\"

foldertosearch = InputBox ("Jaki folder chcesz" &_
"skontrolować?", title ,defaultfoldertosearch)
GoThroughFolders FSO.GetFolder(foldertosearch)
prettynumbermega = formatnumber(totalsize / megaconv,2)
msg = "Rozmiar folderu: " & foldertosearch &_
vbCrLf & vbCrLf & " " & prettynumbermega & " MB"
MsgBox msg,64,title

Sub GoThroughFolders(Folder)
GoThroughFiles (Folder)
For Each Subfolder in Folder.SubFolders
GoThroughFolders Subfolder
Next
End Sub

Sub GoThroughFiles(FolderIn)
For Each objFile in FolderIn.Files
IncrementTotalFileSize(objFile.size)
Next
End Sub

Sub IncrementTotalFileSize(tmpnum)
TotalSize = TotalSize + tmpnum
End Sub

Sub GetFolderToSearch
Set objDialog = CreateObject &_
("UserAccounts.CommonDialog")
objDialog.InitialDir = "C:\"
intResult = objDialog.ShowOpen
If intResult = 0 Then
Wscript.Quit
Else
Wscript.Echo objDialog.FileName
End If
End Sub
-----------

-- 
MICHAL: Mechanical Intelligent Calculation
and Hazardous Assassination Lifeform
BIEK: Being Intended for Exploration
and Killing ...
Received on Thu Jan 21 20:45:03 2010

To archiwum zostało wygenerowane przez hypermail 2.1.8 : Thu 21 Jan 2010 - 21:42:02 MET