|
Answer» I am looking to automate monitoring a specific folders size, and when X size hit, email a notification. I already have the email part. I usually use DTS package through SQL. I am not sure how to FIND out the size of the FOLDER, and then how to use it. Could you use dos command some how, in dts package?for /f "tokens=1-6" %%i in ('dir /s /-C ^| find /i "bytes"') do echo %%k > "size.txt"
How do I just get the first occurrence of bytes?One solution would be a vbscript to get the size of the folder:
Code: [Select] Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder("folderspec") WScript.Echo objFolder.Size
Depending on your SITUATION, you could write the code as a function or a subroutine, which would kick off at regular intervals with the script sleeping in between intervals.
When the folder size exceeded some threshold, the email would get cranked up.
Hope this helps.
Thank You!!!
I used the size property of Scripting.FileSystemObject in a DTS Package. I set up a task RESPONSIBLE for emailing. Then in the workflow properties of the task, I set it up to utilize an active x script. When the active x script returns true, I execute task, and send email. When false, I do nothing.
Thanks for leading me in a direction to solve my issue!
********************************************************************** ' Visual Basic ActiveX Script '************************************************************************
' Folder Size Option Explicit
Function Main()
Dim OFSO Dim oFolder Dim sSourceFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
sSourceFile = "\\server\folder\directory\"
Set oFolder = oFSO.GetFolder(sSourceFile)
If oFolder.Size > 52428800 Then Main = DTSStepScriptResult_ExecuteTask Else Main = DTSStepScriptResult_DontExecuteTask End If
' Clean Up Set oFolder = Nothing Set oFSO = Nothing End Function
|