I am hoping that someone will be able to help. I have a script that will delete files according to a date created, but refuses on a date modified with the error "Object does not support this property or method: 'srcFile.DateModified'. Can someone please tell me where I am going wrong, or rather what I can do to put it right! Here is the script:
/code
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFilesa fso.GetFolder("D:\MyPath\TestDir")
Sub DeleteFilesa(srcFolder)
Dim srcFile
If srcFolder.Files.Count = 0 Then
Wscript.Echo "No File to Delete"
Exit Sub
End If
For Each srcFile in srcFolder.Files
If DateDiff("d", Now, srcFile.DateModified) < -7 Then
fso.DeleteFile srcFile, True
End If
Next
Wscript.Echo "Files Deleted successful"
End Sub
/code
/code
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFilesa fso.GetFolder("D:\MyPath\TestDir")
Sub DeleteFilesa(srcFolder)
Dim srcFile
If srcFolder.Files.Count = 0 Then
Wscript.Echo "No File to Delete"
Exit Sub
End If
For Each srcFile in srcFolder.Files
If DateDiff("d", Now, srcFile.DateModified) < -7 Then
fso.DeleteFile srcFile, True
End If
Next
Wscript.Echo "Files Deleted successful"
End Sub
/code