Removing folders smaller than n size

Caporegime
Joined
25 Jul 2003
Posts
40,281
Location
FR+UK
How might one achieve something similar to:

Code:
du | awk '$1 <= 1000000 { print "rm -rf \"" substr($0, length($1)+2) "\""}' | sh
(this searches for folders smaller than 1MB in size and removes them)

on a Windows server? I'm having a hunt for some powershell but my knowledge is pretty limited..
 
Ok for anyone thats interested, solved with some vb:

Code:
Dim objFD
Set objFD = CreateObject("Scripting.FileSystemObject")
Set objSelectedFolder = objFD.GetFolder("D:\scripttest\")
Set colSubfolders = objSelectedFolder.SubFolders
For Each objSubfolder In colSubfolders
If objSubfolder.Size < 10000000 Then
objSubfolder.Delete True
End If
Next

This will delete any folder less than 10Mb.
 
Back
Top Bottom