zero1de
Technical User
- Oct 17, 2005
- 4
Hi,
I need a script which looks up into the subfoldern if there are more than 5 subfolder exists, then delete the oldest folder until 5 remains.
Create a log File and write ever delete processes to the logfile.
Example: Under this archive D:\also\ will allways create new Folder names xx_207, xx_208, xx_209 this folder should be keept
I need only to Delete the sub-subfolder
D:\also\xx_207\archiv\20091221
D:\also\xx_207\archiv\20091222
D:\also\xx_207\archiv\20091223
D:\also\xx_207\archiv\20091224
D:\also\xx_207\archiv\20091225
D:\also\xx_207\archiv\20091226
D:\also\xx_207\archiv\20091227
Delete
D:\also\xx_207\archiv\20091226
D:\also\xx_207\archiv\20091227
My Code delete everthin can some one help me ??
Dim fso, f, f1, fc, strComments, strScanDir
strDir = "d:\dwh"
strDays = 7
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(strDir)
If f.SubFolders.Count > 5 Then
For Each sf In f.SubFolders
If DateDiff("d", sf.DateCreated, Date) > strDays Then
sf.Delete True
End If
Next
End If
I need a script which looks up into the subfoldern if there are more than 5 subfolder exists, then delete the oldest folder until 5 remains.
Create a log File and write ever delete processes to the logfile.
Example: Under this archive D:\also\ will allways create new Folder names xx_207, xx_208, xx_209 this folder should be keept
I need only to Delete the sub-subfolder
D:\also\xx_207\archiv\20091221
D:\also\xx_207\archiv\20091222
D:\also\xx_207\archiv\20091223
D:\also\xx_207\archiv\20091224
D:\also\xx_207\archiv\20091225
D:\also\xx_207\archiv\20091226
D:\also\xx_207\archiv\20091227
Delete
D:\also\xx_207\archiv\20091226
D:\also\xx_207\archiv\20091227
My Code delete everthin can some one help me ??
Dim fso, f, f1, fc, strComments, strScanDir
strDir = "d:\dwh"
strDays = 7
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(strDir)
If f.SubFolders.Count > 5 Then
For Each sf In f.SubFolders
If DateDiff("d", sf.DateCreated, Date) > strDays Then
sf.Delete True
End If
Next
End If