Hi all,
Im having problems with a script.
Im trying to create a script that check if date of folders in a path are older than 30 days and delete them.
But the hard part is that i need to check in a second level, for example:
C:\path\folder1\folder2
The folder i wanna check is folder2 and in the same level of folder 1 exists more folders.
I add my code and please if u can help this scripting Noob :(((
Option Explicit
Dim objSistema
Dim objCarpeta
Dim objDirectorio
Dim Fecha_Antiguedad
Dim Ruta
Ruta = "c:\Example"
Fecha_Antiguedad = DateAdd("d",-30, Date )
Set objSistema = CreateObject("Scripting.FileSystemObject")
Set objCarpeta = objSistema.GetFolder(Ruta)
For Each objDirectorio In objCarpeta.SubFolders
If DateValue(objDirectorio.DateCreated) <= DateValue(Fecha_Antiguedad) Then
objDirectorio.Delete
End If
Next
Set objDirectorio = Nothing
Set objCarpeta = Nothing
Set objSistema = Nothing
THANKS IN ADVANCE!
<message edited by abizanda on Monday, November 07, 2011 12:05 AM>