Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help for writing a script

Status
Not open for further replies.

gkaher

MIS
Dec 13, 2008
1
HK
Hi Guys/Girls,

I very new to VBscript and now Im in need to perform a task which I think VBscript can do it very well.

I have to delete files from a folder which are 7 days old based on the date when files are added in this folder but not on creation or date modified .

I will apprieciate if some kind soul can help me in this.

Thanks All

Happy Xmas :)

GK
 
Hello gkaher,

I found this online, it should be able to point you in the right direction!

[highlight]Age-Based-File-Deletion[/highlight]

CHAOS, PANIC, & DISORDER - my work here is done.

I currently use Access 2003.
 
If you havent found the answer yet, give this a try !!!

Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
' Replace the <Yourfolder> below with the name of your folder
Set f = fso.GetFolder("J:\<YourFolder>")
Set fc = f.Files
For Each f1 in fc
If DateDiff("d", f1.DateLastModified, Now) > 7 Then
f1.Delete
End If
Next
Set fso = Nothing
Set f = Nothing
Set fc = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top