Script to delete files older than a specific date in a directory 
Author Message
 Script to delete files older than a specific date in a directory

Hi there,
I have application on window 2000 that will create hundreds of file each
day.  I would like to schedule a daily task to delete files older than a
certain date, e.g. a week from today.
Please advise what alternatives I can do this.
Thanks in advance.


Mon, 21 Nov 2005 08:36:55 GMT  
 Script to delete files older than a specific date in a directory

Quote:

> Hi there,
> I have application on window 2000 that will create hundreds of file
> each day.  I would like to schedule a daily task to delete files
> older than a certain date, e.g. a week from today.
> Please advise what alternatives I can do this.
> Thanks in advance.

Hi, John
Google knows:
http://groups.google.com/groups?selm=3DA1A19B.DF9B06D7%40hydro.com

-Paul Randall



Mon, 21 Nov 2005 08:56:47 GMT  
 Script to delete files older than a specific date in a directory
Cwashington Rules

http://cwashington.netreach.net/depo/view.asp?Index=723&ScriptType=vb...

--
Anthony B
------------------------
I pretend to work, they pretend to pay me


Quote:
> Hi there,
> I have application on window 2000 that will create hundreds of file each
> day.  I would like to schedule a daily task to delete files older than a
> certain date, e.g. a week from today.
> Please advise what alternatives I can do this.
> Thanks in advance.



Mon, 21 Nov 2005 08:54:57 GMT  
 Script to delete files older than a specific date in a directory

: Hi there,
: I have application on window 2000 that will create hundreds of file each
: day.  I would like to schedule a daily task to delete files older than a
: certain date, e.g. a week from today.
: Please advise what alternatives I can do this.
: Thanks in advance.
:

Try this

Option Explicit
dim fso, file, daysBack, toDelete(100000), i, ii
daysBack = 7
Set fso = CreateObject("Scripting.FileSystemObject")

For Each file In fso.GetFolder("C:\test\").files
  If DateValue(file.datelastModified) < DateValue(Now - daysBack) Then
    toDelete(i) = file.Path
    i = i + 1
  End If
Next

for ii = 0 to i-1
  fso.DeleteFile (toDelete(ii))
next

Set fso = Nothing
msgbox "complete"



Mon, 21 Nov 2005 08:59:22 GMT  
 Script to delete files older than a specific date in a directory


====================================
today=date()
DaysOld=0
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFolder=objFSO.GetFolder("E:\shared\upload")
Set colSubfolders=objFolder.subfolders
For Each objSubFolder in colSubFolders
    DaysOld=Datediff("d",objSubfolder.DateCreated,today)
    IF DaysOld > 7 Then
       objSubFolder.Delete
    End If
Next
====================================

--
Posted via http://dbforums.com



Mon, 21 Nov 2005 16:23:22 GMT  
 Script to delete files older than a specific date in a directory
Thanks for all the help.


Quote:


> ====================================
> today=date()
> DaysOld=0
> Set objFSO=CreateObject("Scripting.FileSystemObject")
> Set objFolder=objFSO.GetFolder("E:\shared\upload")
> Set colSubfolders=objFolder.subfolders
> For Each objSubFolder in colSubFolders
>     DaysOld=Datediff("d",objSubfolder.DateCreated,today)
>     IF DaysOld > 7 Then
>        objSubFolder.Delete
>     End If
> Next
> ====================================

> --
> Posted via http://dbforums.com



Tue, 22 Nov 2005 10:09:27 GMT  
 
 [ 6 post ] 

 Relevant Pages 

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

2. VBS to delete files in a directory older than 30 days

3. Deleting files and folders older than a particular date

4. Deleting log files older than current date

5. ms-access - delete old dates and change dates

6. Script to delete files older than 5 days?

7. Script to search PST files and delete old messages

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

9. delete records that are older than a certain date

10. deleting logfiles older than current date

11. Script to delete files in a set of Directories

12. Script that deletes multiple files in a directory

 

 
Powered by phpBB® Forum Software