Batch file to delete folders smaller than 3MB

August 6, 2010 at 18:20:58
Specs: Windows XP
Is it possible to create a batch file or .vbs script to delete subdirectories smaller than say 3MB from a parent directory? The delete function needs to be done on the basis of folder size, not file size. Thanks.

See More: Batch file to delete folders smaller than 3MB

Report •

August 6, 2010 at 22:33:44
I dunno vbs but a batch will report every folder as size 0.

Helping others achieve escape felicity


Report •

August 7, 2010 at 01:04:19
This .vbs file seems to work - cobbled together from a number of resources.

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSelectedFolder = objFSO.GetFolder("C:\my folder")
Set colSubfolders = objSelectedFolder.SubFolders
For Each objSubfolder In colSubfolders
If objSubfolder.Size < 50000000 Then
objSubfolder.Delete True
End If

Report •

Related Solutions

Ask Question