Re: Delete files older than a week

D

Dave Patrick

Something like this may work.

Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("J:\aaaa")
Set fc = f.Files
For Each f1 in fc
If DateDiff("d", f1.DateLastModified, Now) > 7 Then f1.Delete
Next
 
E

Eric

Thanks Patrick!

Never done Batch file programming before. Do I need to
save it with the ".bat" extension? How does this work and
does it work during a reboot, does it prompt you to
delete them or what.
-----Original Message-----
Something like this may work.

Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("J:\aaaa")
Set fc = f.Files
For Each f1 in fc
If DateDiff("d", f1.DateLastModified, Now) > 7 Then f1.Delete
Next

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft MVP [Windows NT/2000 Operating Systems]

Eric said:
I need to write a batch file that will delete files
certain folder (or a directory) that is older than a 7
days. Is this possible? How would I go about doing
this?


.
 
E

Eric

Since it is a VBscript, what do I need to save the file.
What file extension?

-----Original Message-----
Not a shell script, but a VBScript

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft MVP [Windows NT/2000 Operating Systems]

Eric said:
Thanks Dave!

Never done Batch file programming before. Do I need to
save it with the ".bat" extension? How does this work and
does it work during a reboot, does it prompt you to
delete them or what.


.
 
D

Dave Patrick

Forgot to mention; no there will be no prompt, the files will just be
deleted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top