1 reply
by damianm
It may be possible to create a simple batch file to do this, however a VBScript would seem to the simplest way to do this. The following example deletes files based on size. It is taken from "Windows Admin Scripting: Little Black Book" by Jesse Torres:
Set FSO = CreateObject("Scripting.FileSystemObject")
sDir = "directory"
lSIZE = lowersize
uSIZE = uppersize
Set objDIR = GetFolder(sDIR)
GoSubFolders objDIR
Sub MainSub (objDIR)
For Each efile in objDIR.Files
If lSIZE = Null and uSIZE = Null Then
If eFile.Size = 0 Then
DelFile efile
End If
ElsiIf lSIZE <> Null and uSIZE = Null Then
If efile.Size < lSIZE Then
DelFile efile
End If
ElseIf lSIZE = Null and uSIZE <> "" Then
If efile.size > uSIZE Then
DelFile efile
End If
ElseIf lSIZE = uSIZE Then
If efile.size = lSIZE Then
DelFile efile
End If
Else
If efile.Size >lSIZE and efile.SIZE < uSIZE Then DelFile efile
End If
End If
Next
End Sub
This discussion is closed to new replies.
Trending Windows Forum posts
Sort by Trending