![]() |
Delete File(s) over a certain age
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 |
Delete File(s) over a certain age
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 |
All times are GMT +1. The time now is 02:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com