Question

  Asked: May 8 2008   2:31 PM GMT
  Asked by: Pandub


Script to delete old log files on Win server 2003


Windows scripting, Scripting, Windows Server 2003, Batch files

Hi all,
looking for a script or batch file that I can call from schedule tasks that will delete some older symantec log files that keep filling up my c: drive.

Any suggestion or pointers would be appreciated.
thanks in advance
paul

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0



Hello, I think that this will solve your problem, just save the following code as whateveryoulike.vbs and schedule it (remember: the user that runs the scheduled job must have access to the "WhatchFolder ").


Const WhatchFolder = "C:\TheFolder"
Const MaxDays = 30
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(WhatchFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If DateDiff("d",objFile.DateCreated,now) >= MaxDays Then
objFSO.DeleteFile(objFile.Path)
End If
Next


I hope this helps.
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Microsoft Windows.

Looking for relevant Microsoft Windows Whitepapers? Visit the SearchEnterpriseDesktop.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Jlees  |   May 9 2008  6:15PM GMT

You can do this with the file system object in vbscript, relatively easily. What is the format of the names of the files you wish to delete? Is the date encoded intt the file?