I just want the dang folder size!

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
ueberyak
Junior Coder
Posts: 31
Joined: Tue Sep 03, 2013 9:45 pm

I just want the dang folder size!

Post by ueberyak » Fri Mar 06, 2015 5:58 pm

I have a portion of a script that I only want to run when a folder's size changes. I need to use folder size because it contains a zillion subfolders, subsubfolders, etc. and I won't ever know what changed.

I have the following, but it returns way more information than I need. The other issue is that if I were to run this for the actual folder I'm interested in, it'd run for a really long time.

Code: Select all

let>oDirectory=C:\FolderSizeTest\
Let>RP_WINDOWMODE=2
Let>RP_WAIT=1

Run>cmd /c dir %oDirectory% /s | find "(s)" > C:\FolderSizeReport\FolderSize.txt
Thanks,
Josh

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: I just want the dang folder size!

Post by Marcus Tettmar » Mon Mar 09, 2015 10:45 am

Hi,

Try this:

Code: Select all

VBSTART
  Function GetFolderSize(Path)
     Set objFSO = CreateObject("Scripting.FileSystemObject")
     Set objFolder = objFSO.GetFolder(Path)
     GetFolderSize = objFolder.Size
  End Function
VBEND

VBEval>GetFolderSize("c:\temp"),fSize
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

ueberyak
Junior Coder
Posts: 31
Joined: Tue Sep 03, 2013 9:45 pm

Re: I just want the dang folder size!

Post by ueberyak » Mon Mar 09, 2015 5:36 pm

You are a legend! Thanks, Marcus!
Thanks,
Josh

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts