General discussion

Locked

Script file

By ilene521 ·
Does anyone know of a web site where I can fine examples or find a bat file to check the size of a file? I want to check files sizes as I back them up.

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Script file

by DamianM In reply to Script file

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

Back to Windows Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums