Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch to auto-delete files that have not been modified within 30 days

Status
Not open for further replies.

33788

IS-IT--Management
Mar 15, 2005
97
0
0
US
We have a drive on the server that we would like to write a batch file or some program that will automatically delete files that have not been modified within 30 days. All files will already get backed up by the backup library. Has anybody ever been able to do this with just a regular DOS batch file? I'm not good with VB or other scripting. Any help would be appreciated. Tried to do it with the backup application ARCserve 11.5 SP2 but that feature is not available. They suggest I find a different work around. If it's a batch file I can just use the regular Windows Scheduler to run the file every 30 days. Thanks ahead.
 
Which option have you tried in Arcserve. We are able to do this just fine.

Create a filter that only includes all files have a modified date of > 30 days. (Run the job the first time and make sure it only backups the files you want to get rid of).

Then in the options of the job select the "Delete Files after backup" (might be remove files).

These two options together seem to work fine.

Note : The "accessed filter" does not work. Modified and Created work fairly well.

 
Thanks for your response mrtoledo. I have looked into those features and read the instructions which was very confusing. I'm pretty new with ARCserve that's definately one of the issues. I to heard it was possible but could not get it to work. Did you have to schedule a seperate job to get this accomplished? We have a regular GFS backup going on Mon. - Fri. I notice the delete feature is a global option which will effect all the backups. I'm guessing the only way to make it not effect all is setup a new job? Any light you can shead on this little issue would greatly be appreciated, thanks.
 
Here you go, I modified one of my scripts from my Admin Script Pack for you.

Code:
'==========================================================================
'
' NAME: Clean30DayOld.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL   : [URL unfurl="true"]http://www.thespidersparlor.com[/URL]	
' COPYRIGHT (c) 2003 All rights reserved
' DATE  : 09/10/2003
'
' COMMENT: 
'
' This script will delete files that have not been 
' modified in more than 30 days.
' This file is to be scheduled to run each day.
'
'    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
'    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED To
'    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'=====================================

Path1 = "E:\Program Files\Exchsrvr\Mailroot\vsi 1\BadMail"
Dim fso, oFolder, oFile


  Set fso = createobject("Scripting.FileSystemObject")
  
   Set oFolder = fso.GetFolder(Path1)
  
  For Each oFile In oFolder.files
   	If DateDiff("d", oFile.DateLastModified,Now) > 30 Then
    	oFile.Delete True
    End If
  Next

Set oFolder = Nothing
Set fso = Nothing

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top