시스템/Linux
스크립트 - 일정기간 이후의 파일을 자동 삭제하는 스크립트
달빛궁전-
2012. 5. 8. 20:33
예전에 IDC에서 근무할 떄 만들었던 스크립트
아래 참조
'30일지난 파일 자동 삭제하는 스크립트
Option Explicit
'삭제할 파일이 있는 폴더 지정 및 날짜 지정
Const strRootPath = "D:\WEBLOG"
Const nDays = 30
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oFolder, oSubFolder
Set oFolder = oFSO.GetFolder(strRootPath)
Dim oFile
'지정된 폴더 안의 파일 삭제
For Each oFile In oFolder.Files
If Int(Now() - oFile.DateLastAccessed) >= nDays Then
oFile.Delete
End If
Next
'지정된 폴더 하위 폴더 안의 파일 삭제
For Each oSubFolder In oFolder.SubFolders
For Each oFile In oSubFolder.Files
If Int(Now() - oFile.DateLastAccessed) >= nDays Then
oFile.Delete
End If
Next
Next