|
|
|
|
|
|
|
|
|
Re: Delete archive logs automatically using script in windows [message #347457 is a reply to message #347386] |
Thu, 11 September 2008 13:00   |
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.
|
|
|
|
|