PC Review


Reply
Thread Tools Rate Thread

Date Based File Purge

 
 
=?Utf-8?B?U3RpbmdyYXk=?=
Guest
Posts: n/a
 
      6th Oct 2006
I am looking for a solution to a problem I've been wrestling with for a
couple years and so far I've hid dead ends. I have a low-end NAS device that
we use for storage of our security camera files and have a need to
periodically remove files older than a given date. The big problem is, since
it's a Unix based OS rather than Windows Storage Server based, we cannot
connect to it directly with our backup server, which would be able to do a
simple archive backup and purge the backed up files for us.

I've been searching through utility packages and scripting sites and have
not found anywhere how I could automate the process of searching a directory
tree on a mapped drive and delete any files older than a specified date. Does
anyone out there have any ideas? I'd prefer something that's already written
but I'm not totally opposed to some coding as long as it doesn't get to
advanced. I appreciate any advice or suggestions.


 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      6th Oct 2006

"Stingray" <(E-Mail Removed)> wrote in message
news:C34BADBB-AE98-4B21-B228-(E-Mail Removed)...
> I am looking for a solution to a problem I've been wrestling with for a
> couple years and so far I've hid dead ends. I have a low-end NAS device

that
> we use for storage of our security camera files and have a need to
> periodically remove files older than a given date. The big problem is,

since
> it's a Unix based OS rather than Windows Storage Server based, we cannot
> connect to it directly with our backup server, which would be able to do a
> simple archive backup and purge the backed up files for us.
>
> I've been searching through utility packages and scripting sites and have
> not found anywhere how I could automate the process of searching a

directory
> tree on a mapped drive and delete any files older than a specified date.

Does
> anyone out there have any ideas? I'd prefer something that's already

written
> but I'm not totally opposed to some coding as long as it doesn't get to
> advanced. I appreciate any advice or suggestions.
>
>


Both xxcopy.exe and robocopy.exe have switches that let
you delete files selectively. xxcopy is downloadable from a
number of sites and robocopy comes with the Windows
Resource Kit.


 
Reply With Quote
 
n_t_schultz@hotmail.com
Guest
Posts: n/a
 
      4th Dec 2006
Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c::\test")
Set fc = f.Files
For Each f1 in fc
If DateDiff("d", f1.DateLastModified, Now) > 15 Then
f1.Delete
End If
Next
Set fso = Nothing
Set f = Nothing
Set fc = Nothing


This VB script was posted in another forum that should help you. I am
checking with a friend to see if he can modify the script so I can also
specify a file type as well. When I get that one back I will post it
too.

 
Reply With Quote
 
n_t_schultz@hotmail.com
Guest
Posts: n/a
 
      5th Dec 2006
I have done some basic testing on revised script on the code provided
earlier. This VB code will allow you to specify the folder, file
extension, and date.

FYI you will need to save the file as a VBS and the run it from the
command like this:

wscript filename.vbs
or like
cscript filename.vbs


Dim fso, f, f1, fc
Dim temp, pos
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\test") 'Gets the folder
Set fc = f.Files 'gets all of the files in the folder, makes a
collection
For Each f1 in fc 'increments through each of the files in fc
temp = f1.name 'get file name
temp=right(temp,4) 'get the last 4 characters in the string (match
this to the number of characters in the if statement (.txt = 4)
if(temp = ".txt" AND DateDiff("d", f1.DateLastModified, Now) >
15) then 'only delete if it is the correct file type and so old
f1.delete
end if
Next
Set fso = Nothing
Set f = Nothing
Set fc = Nothing

 
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
Open file with variable date name based on current date Ciprian Microsoft Excel Programming 1 7th Jan 2010 02:31 PM
Can't purge date object into sql string for access dbase Chumley Walrus Microsoft Access Queries 0 26th Jun 2006 08:08 PM
Purge data based on another Excel file??? =?Utf-8?B?RnJhbms=?= Microsoft Excel Misc 0 6th Sep 2005 05:12 PM
Purge Data Based on Cell Color and Time =?Utf-8?B?VG9kZA==?= Microsoft Excel Programming 5 23rd May 2005 08:38 PM
Re: Macro for file name based on date Bob Phillips Microsoft Excel Worksheet Functions 1 22nd Aug 2003 11:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:12 AM.