PC Review Forums Newsgroups Windows 2000 Microsoft Windows 2000 Deployment Re: Delete files older than a week

Reply

Re: Delete files older than a week

 
Thread Tools Rate Thread
Old 01-07-2003, 08:32 PM   #1
Dave Patrick
Guest
 
Posts: n/a
Default Re: Delete files older than a week


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" wrote:
> 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?



  Reply With Quote
Old 01-07-2003, 09:13 PM   #2
Eric
Guest
 
Posts: n/a
Default Re: Delete files older than a week

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" wrote:
>> 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?
>
>
>.
>

  Reply With Quote
Old 01-07-2003, 11:24 PM   #3
Dave Patrick
Guest
 
Posts: n/a
Default Re: Delete files older than a week

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" wrote:
> 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.



  Reply With Quote
Old 02-07-2003, 12:43 AM   #4
Eric
Guest
 
Posts: n/a
Default Re: Delete files older than a week

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" wrote:
>> 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.

>
>
>.
>

  Reply With Quote
Old 02-07-2003, 12:55 AM   #5
Dave Patrick
Guest
 
Posts: n/a
Default Re: Delete files older than a week

VBS

--
Regards,

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

"Eric" wrote:
> Since it is a VBscript, what do I need to save the file.
> What file extension?



  Reply With Quote
Old 02-07-2003, 02:11 AM   #6
Dave Patrick
Guest
 
Posts: n/a
Default Re: Delete files older than a week

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

--
Regards,

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


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off