G
Guest
Dear Experts,
The following script deletes folders that are
more than 1 day old:
dtmYesterday = Date - 1
strYear = Year(dtmYesterday)
strMonth = Month(dtmYesterday)
If Len(strMonth) = 1 Then
strMonth = "0" & strMonth
End If
strDay = Day(dtmYesterday)
If Len(strDay) = 1 Then
strDay = "0" & strDay
End If
strYesterday = strYear & strMonth & strDay
strFolderName = "D:\Reports\" & strYesterday
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder(strFolderName)
and my folders are as follows:
D:\Reports\20051102
D:\Reports\20051103
If I run the above script on Nov 9 it would return me
the following message:
error: path not found
code: 800A004C
Source: Microsoft VBScript runtime error
(as 20051108 does not exist)
Question - how do I add a script to ignore folders
that do not exist?
Thanks in advance.
The following script deletes folders that are
more than 1 day old:
dtmYesterday = Date - 1
strYear = Year(dtmYesterday)
strMonth = Month(dtmYesterday)
If Len(strMonth) = 1 Then
strMonth = "0" & strMonth
End If
strDay = Day(dtmYesterday)
If Len(strDay) = 1 Then
strDay = "0" & strDay
End If
strYesterday = strYear & strMonth & strDay
strFolderName = "D:\Reports\" & strYesterday
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder(strFolderName)
and my folders are as follows:
D:\Reports\20051102
D:\Reports\20051103
If I run the above script on Nov 9 it would return me
the following message:
error: path not found
code: 800A004C
Source: Microsoft VBScript runtime error
(as 20051108 does not exist)
Question - how do I add a script to ignore folders
that do not exist?
Thanks in advance.