Home » Infrastructure » Windows » Delete archive logs automatically using script in windows (Windows server 2003 R2)
Delete archive logs automatically using script in windows [message #347386] Thu, 11 September 2008 07:54 Go to next message
dvishnu_apps
Messages: 34
Registered: September 2008
Member
Hi,

Can you please provide the script that automatically deletes the archive logs from the past 15 days or 1 month in the windows platform.

The archive log loction is D:\archive.

Thanks,
Vishnu
Re: Delete archive logs automatically using script in windows [message #347388 is a reply to message #347386] Thu, 11 September 2008 07:57 Go to previous messageGo to next message
Michel Cadot
Messages: 59147
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Maybe you'll find the answer in Windows forum.

Regards
Michel
Re: Delete archive logs automatically using script in windows [message #347391 is a reply to message #347386] Thu, 11 September 2008 08:05 Go to previous messageGo to next message
dvishnu_apps
Messages: 34
Registered: September 2008
Member
Thank You Very much
Re: Delete archive logs automatically using script in windows [message #347392 is a reply to message #347386] Thu, 11 September 2008 08:08 Go to previous messageGo to next message
dvishnu_apps
Messages: 34
Registered: September 2008
Member
Please provide me the solution as soon as possible as I have to delete large amount of old archive logs in the production system
Re: Delete archive logs automatically using script in windows [message #347428 is a reply to message #347386] Thu, 11 September 2008 11:11 Go to previous messageGo to next message
dvishnu_apps
Messages: 34
Registered: September 2008
Member
Please send me the solution asap
Re: Delete archive logs automatically using script in windows [message #347439 is a reply to message #347428] Thu, 11 September 2008 11:52 Go to previous messageGo to next message
Michel Cadot
Messages: 59147
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Did you just try Google?
I tried to search: "windows list files older than days" and got:
http://www.google.com/search?hl=en&q=windows+list+files+older+than+days&aq=f&oq=

The 6th link gives you a nice solution.
Top! 3 minutes to do the job!

Regards
Michel

[Updated on: Thu, 11 September 2008 11:52]

Report message to a moderator

Re: Delete archive logs automatically using script in windows [message #347449 is a reply to message #347386] Thu, 11 September 2008 12:26 Go to previous messageGo to next message
dvishnu_apps
Messages: 34
Registered: September 2008
Member
Hi,

I went through the 6th link.
But, Please let us know how to run the code.
what language is the code?
Re: Delete archive logs automatically using script in windows [message #347455 is a reply to message #347449] Thu, 11 September 2008 12:49 Go to previous messageGo to next message
Michel Cadot
Messages: 59147
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
windows shell, classical batch file.

Regards
Michel
Re: Delete archive logs automatically using script in windows [message #347456 is a reply to message #347386] Thu, 11 September 2008 12:52 Go to previous messageGo to next message
dvishnu_apps
Messages: 34
Registered: September 2008
Member
Hi,

Please let us know how to execute it.

Thanks,
Vishnu
Re: Delete archive logs automatically using script in windows [message #347457 is a reply to message #347386] Thu, 11 September 2008 13:00 Go to previous messageGo to next message
dvishnu_apps
Messages: 34
Registered: September 2008
Member
Hi,

I created a batch file for the following code:

-------------
' Delete files older than # days...
KillDate = Date() - NoOfDays

' Prepare List of Files to Kill.
KillList = Array()

SelectFiles "D:\FolderToCheck", KillDate, KillList, true

for FileCount = 0 to ubound(KillList)

on error resume next 'in case of 'in use' files...
KillList(FileCount).Delete true
next

Sub SelectFiles(sPath,vKillDate,arFilesToKill,bIncludeSubFolders)

' Get Filesystem Handle.
set Filesystem = createobject("scripting.filesystemobject" )

'select files to delete and add to array...
set folder = Filesystem.getfolder(sPath)
set files = folder.files

for each file in files
' uses error trapping around access to the
' Date property just to be safe
'
dtcreated = null
on error resume Next
dtcreated = file.datecreated
on error goto 0
if not isnull(dtcreated) Then
if dtcreated < vKillDate then
count = ubound(arFilesToKill) + 1
redim preserve arFilesToKill(count)
set arFilesToKill(count) = file
end if
end if
next

if bIncludeSubFolders then
for each fldr in folder.subfolders
SelectFiles fldr.path,vKillDate,arFilesToKill,true
next
end if
end sub
-------

When I execute this batch file in the command prompt,
it is giving an error

'Delete' is not recognized as an internal or external command,
operable program or batch file.
Re: Delete archive logs automatically using script in windows [message #347458 is a reply to message #347457] Thu, 11 September 2008 13:33 Go to previous messageGo to next message
Michel Cadot
Messages: 59147
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is VBScript not batch file.
You can download VBScript from internet on microsoft site.
You also use the simple trick described at http://forums.devshed.com/showpost.php?p=1539355&postcount=2

Regards
Michel

Re: Delete archive logs automatically using script in windows [message #347472 is a reply to message #347457] Thu, 11 September 2008 16:50 Go to previous message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
Search of the forum would of revealed this.
Previous Topic: Antivirus Software
Next Topic: intalled oracle 9i
Goto Forum:
  


Current Time: Sat Sep 20 23:11:45 CDT 2014

Total time taken to generate the page: 0.11219 seconds