VBS to delete files in a directory older than 30 days 
Author Message
 VBS to delete files in a directory older than 30 days

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

begin 666 Mitchell L Belew.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..D)E;&5W.TUI=&-H96QL.TP-

M-C W.0T*5$5,.TA/344[1D%8.C4Q,RTU,CDM-C W.0T*0412.TA/344Z.SLT


M(%)U;B!4<F%I;" C,STP1#TP04-I;F-I;FYA=&DL($]((#0U,C4U/3!$/3!!
M55,-"D5-04E,.U!2148[24Y415).150Z;6)E;&5W0&9U<V4N;F5T#0I2158Z

`
end



Wed, 29 May 2002 03:00:00 GMT  
 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



Wed, 29 May 2002 03:00:00 GMT  
 VBS to delete files in a directory older than 30 days


Quote:
>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

Try
        dfile = dateadd("d",-30,date) : ' Set dfile to 30 days ago

otherwise
        dfile = date - 30

might also work (although it begs the question why have a dateadd
function ?)

They both work on my machine.

Steve



Thu, 30 May 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Delete Files 3 days old

2. Delete files older than n days.

3. Delete files when they are X days old.

4. Script to delete files older than 5 days?

5. Looking for script to delete files older than X days

6. Find and delete files in a folder older than 2 days

7. How to delete all files which are X number of days old

8. Script to delete files older than a specific date in a directory

9. Script to delete files older than a specific date in a directory

10. Exchange Mailbox not accessed for 30 days

11. Create Task view Next 14, 30 days?

12. Strategies and Techniques for making 30-Day Trial Software

 

 
Powered by phpBB® Forum Software