Technology Questions

Go Back   Technology Questions > Software Questions > Operating System Questions > Windows XP

Windows XP Discuss the Microsoft Windows XP Operating System

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 01-04-2007, 01:46 AM
Stingray
Newsgroup Contributor
 
Posts: n/a
Date Based File Purge

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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

 
Old 01-04-2007, 01:46 AM
  #2 (permalink)  
Old 01-04-2007, 01:46 AM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Date Based File Purge


"Stingray" <Stingray@discussions.microsoft.com> wrote in message
news:C34BADBB-AE98-4B21-B228-CE103B93B8C8@microsoft.com...
> 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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 01-04-2007, 05:30 AM
n_t_schultz@hotmail.com
Newsgroup Contributor
 
Posts: n/a
Re: Date Based File Purge

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 01-04-2007, 05:30 AM
n_t_schultz@hotmail.com
Newsgroup Contributor
 
Posts: n/a
Re: Date Based File Purge

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 01-04-2007, 05:33 AM
n_t_schultz@hotmail.com
Newsgroup Contributor
 
Posts: n/a
Re: Date Based File Purge

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #6 (permalink)  
Old 01-04-2007, 05:33 AM
n_t_schultz@hotmail.com
Newsgroup Contributor
 
Posts: n/a
Re: Date Based File Purge

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools

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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Batch file to rename file based on file size Brandon Windows XP 14 10-17-2008 01:45 AM
how to sort chinese file names based on pronunciation? ns666ns@yahoo.com Windows XP 2 07-31-2007 04:30 PM
WMDC Changes File Date When copying file to Laptop Bob Windows Vista 4 03-28-2007 03:15 PM
Move Files in DOS Based on Date Jerry Windows XP 4 01-04-2007 04:19 AM
Determining processor type based on MSinfo32 .nfo file CoolerThanYou Windows XP 7 01-04-2007 03:51 AM


New To Technology Questions? Do You Need Help with Your Computer or Device? Do You Need Help with this site?

All times are GMT -8. The time now is 05:25 PM.


2003 - 2009 All Rights Reserved. Technology Questions

Search Engine Friendly URLs by vBSEO 3.3.0