Solved

total size of a directory

Posted on 2011-03-07
4
281 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:drtopserv
4 Comments
 
LVL 16

Accepted Solution

by:
santoshmotwani earned 400 total points
ID: 35055178
wscript.exe DELETE.vbs

Dim objFD
Set objFD = CreateObject("Scripting.FileSystemObject")
Set objSelectedFolder = objFD.GetFolder("path to sample folder")
Set colSubfolders = objSelectedFolder.SubFolders
For Each objSubfolder In colSubfolders
If objSubfolder.Size < 3000000 Then
objSubfolder.Delete True
End If
Next

ref :http://www.computing.net/answers/programming/batch-file-to-delete-folders-less-than-3mb/22099.html
0
 
LVL 10

Assisted Solution

by:wls3
wls3 earned 100 total points
ID: 35058583
The following scripting guys link will help you get folder sizes:
http://technet.microsoft.com/en-us/library/ff730945.aspx
0
 

Author Closing Comment

by:drtopserv
ID: 35224822
Thnx it works in vbscript . i needed it for batch .but still OK
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 35227700
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
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Set OWA language and time zone in Exchange for individuals, all users or per database.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question