
VBS to delete files in a directory older than 30 days
dt = date() - 30
msgbox dt
dt = dateadd("m",-1,date())
msgbox dt
dt = #12/31/1999# - 30
msgbox dt
dt = dateadd("m",-1,#12/31/1999#)
msgbox dt
--
Michael Harris
At the present, I have to pass the date to the VBS. The script is as
follows:
Dim dfile
Set oArgs = Wscript.Arguments
If oArgs.Count <> 2 Then
Wscript.Echo "No file were deleted"
Wscript.Quit 1
End If
If Not IsDate(oArgs(0)) Then
Wscript.Echo "Error: The [date] parameter must be a date value."
Wscript.Echo " Instead it was '" & oArgs(0) & "'."
Wscript.Quit 1
End If
dFile = (oArgs(0))
What I would like to do is to have it look at the current date, then make
dfile = current date - 30 days, in order to delete files older than 30 days.
Anyone have any ideas?
Mitch