![]() Loading |
VBScript |
JavaScript |
Powershell |
Search Options: Delete the Oldest File From a Folder If and When That Folder Exceeds a Specified Size
|
||
strOldestFile = ""
dtmOldestDate = Now Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder("C:\Scripts") intFolderSize = Int((objFolder.Size / 1024) / 1024) If intFolderSize >= 25 Then Set colFiles = objFolder.Files For Each objFile in colFiles strFile = objFile.Path dtmFileDate = objFile.DateCreated If dtmFileDate < dtmOldestDate Then dtmOldestDate = dtmFileDate strOldestFile = strFile End If Next objFSO.DeleteFile(strOldestFile) End If | ||
© 2008 - 2013 Boris Toll :: Scripts available: 6.481 :: :: scriptbox.toll.at :: :: powered by www.toll.at :: |