PC Review


Reply
Thread Tools Rate Thread

Re: Delete files older than a week

 
 
Dave Patrick
Guest
Posts: n/a
 
      1st Jul 2003
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
 
 
 
 
Eric
Guest
Posts: n/a
 
      1st Jul 2003
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
 
Dave Patrick
Guest
Posts: n/a
 
      2nd Jul 2003
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
 
Eric
Guest
Posts: n/a
 
      2nd Jul 2003
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
 
Dave Patrick
Guest
Posts: n/a
 
      2nd Jul 2003
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
 
Dave Patrick
Guest
Posts: n/a
 
      2nd Jul 2003
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
messages older then 1 week disappear, older then 1 month visible =?Utf-8?B?QnJlbg==?= Microsoft Outlook Installation 0 8th Feb 2007 11:13 PM
xcopy files older week =?Utf-8?B?Sm9lIEsu?= Windows XP Basics 2 15th Jun 2006 06:21 AM
Delete files older than X days old. Kenneth Keeley Microsoft Windows 2000 File System 3 1st Sep 2004 01:58 AM
delete files older than X date Scott Closter Microsoft Windows 2000 CMD Promt 4 27th Apr 2004 03:51 PM
Re: delete files older than specified date Torgeir Bakken (MVP) Microsoft Windows 2000 0 10th Sep 2003 11:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:25 PM.