Link to home
Start Free TrialLog in
Avatar of drtopserv
drtopservFlag for Israel

asked on

total size of a directory

Hi,
I need a batch to run and check if a total size of a c:\sample (subdirectory and files included) is less than 3 mb in total then delete SAMPLE folder and it`s subdirectories and files within it.
ASKER CERTIFIED SOLUTION
Avatar of santoshmotwani
santoshmotwani
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of drtopserv

ASKER

Thnx it works in vbscript . i needed it for batch .but still OK
Avatar of Bill Prew
Bill Prew

There are a couple of free utilities you could use from a BAT script to do this, like:

http://technet.microsoft.com/en-us/sysinternals/bb896651.aspx
http://www.gammadyne.com/cmdline.htm#sizeof

It's pretty hard to do with just BAT commands and no helper utility.  The real problem with doing it in BAT is that numbers in BAT are limited to a maximum integer of 2147483648.  That's 2GB.  So if you were to try and process folders that had sizes that exceed that number then weird stuff starts to happen with BAT arithmetic.

If you want to assume that no folders ever exceed that, then using one of those utils in a BAT file could work, if you want help with that let me know.

~bp