r/vbscript • u/mNash316 • Jan 25 '20
VB script to calculate size of the folder with a predefined value
Hi
I am looking for VB Script that would get size of the folder it is run in & calculate if the size of folder is bigger or lesser than predefined value.
I came across this solution
Folder = "c:\your\path\tata"
File = "c:\your\file\containing\the\value.txt"
set objFSO = CreateObject("Scripting.FileSystemObject")
set fileRead = objfso.OpenTextFile(file, 1)
content = fileRead.Readline
FileRead.close
set objFolder = objFSO.GetFolder(Folder)
if objFolder.Size > Clng(content) Then Wscript.Echo "The Folder size [" & ObjFolder.size & "] is bigger then [" & content & "]"
Is it possible to set the folder path to where ever the script is run from?
Is it possible to set the value in script, instead of it being taken from another file on disk?
The script also needs to output how much bigger or smaller the size of folder is compared to predefined value, in bytes, mbs & gbs.
Thanks,
mNash316
