Solved

total size of a directory

Posted on 2011-03-07
4
279 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 52

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

Suggested Solutions

Title # Comments Views Activity
Shell Script on AIX 7 62
Device Type 6 15
change the windows script file to BAT 10 29
Using an inventory file in a script 7 12
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
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…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now