PC Review


Reply
Thread Tools Rate Thread

Delete File(s) over a certain age

 
 
Richard
Guest
Posts: n/a
 
      21st Feb 2008
Hi,

This is obviously a variation on a theme and I realise that the deleted
file(s) will not move to the recycle bin.

On the first business day of a new month ie March, I would like to delete
all the files in a specific folder which are more than a month old, ie from
Jan or before.

I already have a procedure which runs only on the first business day of each
month, so the additional code can be incoprorated into this.

Thanks for your help.

Regards
Richard
 
Reply With Quote
 
 
 
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      21st Feb 2008
> This is obviously a variation on a theme and I realise that the deleted
> file(s) will not move to the recycle bin.


Okay, as long as you realize that the files will not be recoverable...

> On the first business day of a new month ie March, I would like to delete
> all the files in a specific folder which are more than a month old, ie
> from
> Jan or before.
>
> I already have a procedure which runs only on the first business day of
> each
> month, so the additional code can be incoprorated into this.


TEST THE FOLLOWING AGAINST COPIES OF THE ACTUAL FILES FIRST to make sure it
works correctly!!!

' Put these with the rest of your Dim statements
Dim Path As String
Dim FileName As String
' ....
' ....
' Note the trailing backslash... always include it.
Path = "C:\TEMP\Test\"
FileName = Dir$(Path & "*.*")
Do While Len(FileName) > 0
If DateDiff("m", FileDateTime(Path & FileName), #3/1/2008#) > 1 Then
Kill Path & FileName
End If
FileName = Dir$
Loop

Rick

 
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
can i delete an email and skip the delete file as a single step Hugh Microsoft Outlook Discussion 1 8th Apr 2010 01:07 PM
Delete only unread messages in my delete file =?Utf-8?B?U3Vl?= Microsoft Outlook Discussion 3 7th Jul 2005 11:21 AM
Difference between Delete Subfolders and File and Delete =?Utf-8?B?Um9i?= Microsoft Windows 2000 File System 0 29th Jun 2005 03:31 PM
Re: Macro to delete sheets and saves remaining file does not properly delete module gazornenplat Microsoft Excel Programming 0 22nd Jun 2005 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Microsoft Excel Programming 7 21st Jun 2005 05:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:33 PM.