I need some help on below script I am doing a auto delete based on file extension and date modified.
I just started on vbscript so not really sure about how it worked.
I will want it to delete older file based on date and file extension when the first condition is true and if the condition is false it will end
Option Explicit
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objSTR, objTYP, objFILE`enter code here`
Dim Folder, SubFolder
Dim objNetwork, strRemoteshare, strUser, strPassword
Set objNetwork = WScript.CreateObject("WScript.Network")
strRemoteShare = "shared drive path"
strUser = "user"
strPassword = "password"
objNetwork.MapNetworkDrive "X:", strRemoteshare, True, strUser,
strPassword
objNetwork.RemoveNetworkDrive "X:", True , True
objTYP = "file extension"
For Each objFILE In objFSO.GetFolder("folder path").Files
If objFile.Type = objTYP And objFILE.DateLastModified <
DateAdd("d",-5,Now) = True Then
'in the statement here i want it delete the older file based on
'objFile.Type = objTYP And objFILE.DateLastModified > DateAdd("d",-10,Now)
ElseIf objFile.Type = objTYP And objFILE.DateLastModified <
DateAdd("d",-5,Now) = False Then
End If
Next