2010. 8. 25. 16:29

vbs 를 이용한 오래된 파일 삭제

Option Explicit

Const strRootPath = "H:\Backup"
Const nDays = 3 '초과일수

Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")

Dim oFolder, oSubFolder
Set oFolder = oFSO.GetFolder(strRootPath)

Dim oFile
For Each oSubFolder In oFolder.SubFolders
 For Each oFile In oSubFolder.Files
  If Int(Now() - oFile.dateLastModified) >= nDays Then
    oFile.Delete
  End If
 Next
Next