26 Aralık 2011 Pazartesi
Delete folders/files older than a specific day Script
Belli bir günden daha eski klasör/Dosyaları silme Script
----------
' X_TarihdenEskiDosyaSil.vbs Cem 2010
' ***************************************************
' * Bu vbs belirledigimiz tarihden eski file'leri
' * folder ve alt folder'ına bakarak siler
' *
' * Silmek istediğiniz path ve lifetime degiskenlerini girmeniz gerekir
' * Example : path = "\\Dosya\backup"
' * Example : path = "N:\Logfiles"
Path = "C:\WINDOWS\system32\LogFiles"
' * AltFolder'ların içinide silmek için Example : Subfolders = True
' * Sadece tek folder'ı silmek için Example : Subfolders = False
Subfolders = True
' * kac günden eski file'leri silecegiz
' * Example : lifetime = date() - 20
Lifetime = date() - 7
' *******************************************************
FilesArray = Array()
set fso = createobject("scripting.filesystemobject")
SelectFiles path, lifetime, FilesArray, Subfolders
numDeleted = 0
for n = 0 to ubound(FilesArray)
on error resume next
FilesArray(n).delete true
on error goto 0
next
sub SelectFiles(sPath,vlifetime,FilesArrayToKill,bIncludeSubFolders)
on error resume next
set folder = fso.getfolder(sPath)
set files = folder.files
for each file in files
dtlastmodified = null
on error resume Next
dtlastmodified = file.datelastmodified
on error goto 0
if not isnull(dtlastmodified) Then
if dtlastmodified < vlifetime then
count = ubound(FilesArrayToKill) + 1
redim preserve FilesArrayToKill(count)
set FilesArrayToKill(count) = file
end if
end if
next
if bIncludeSubFolders then
for each fldr in folder.subfolders
SelectFiles fldr.path,vlifetime,FilesArrayToKill,true
next
end if
end sub
----------
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder