Script to delete files after a set number
Hello to all. I am trying to create a script that will delete files in a folder after the file count reaches a specific number, say, 7.
This is what I have written:
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFiles fso.GetFolder("C:\Test")
Sub DeleteFiles(srcFolder)
Dim srcFile
If srcFolder.Files.Count > 7 Then
objFSO.DeleteFile
Exit Sub
End If
End Sub
I know it is wrong as it returns error messages. Could someone help me with this script? Also, could you recommend a good book or website which would helpd me going forward?
Thanks
-John-
John
|