Delete Files1

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

strComputer = ".

" strCurrentDate = Date strbackup ="C:\Informatica\powenter\seer\infa_shared\Backup" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") if strbackup ="C:\Inforatica\powercenter\server\infa_sred\Backup" then Set colFiles = objWMIService.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='C: \Informatica\pownter\server\infaed\Backup' Where ResultClass = CIM_DataFile") For Each objFile In colFiles wscript.echo objFile.name strFileDate = WMIDateStringToDate(objFile.CreationDate) intHours = DateDiff("h",strFileDate,strCurrentDate) msgbox strCurrentDate msgbox intHours intCd = Instr(objFile.name,"lkp") msgbox intCd If (intHours >= 24 )Then objFile.Delete End If Next end if strbad="C:\Informatica\powerer\server\inared\Badfiles" if strbad ="C:\Informatica\powercenter\servr\infared\Badfiles" then Set colFiles1 = objWMIService.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='C :\Informatica\powter\server\infared\Badfiles'} Where ResultClass = CIM_DataFile" ) For Each objFile In colFiles1s wscript.echo objFile.name strFileDate = WMIDateStringToDate(objFile.CreationDate) intHours = DateDiff("h",strFileDate,strCurrentDate) msgbox strCurrentDate msgbox intHours intCd = Instr(objFile.name,"lkp") msgbox intCd If (intHours >= 24 )Then objFile.Delete End If Next end if

Function WMIDateStringToDate(dtmInstallDate) msgbox dtmInstallDate WMIDateStringToDate = CDate(Mid(dtmInstallDate, 5, 2) & "/" & _ Mid(dtmInstallDate, 7, 2) & "/" & Left(dtmInstallDate, 4) _ & " " & Mid (dtmInstallDate, 9, 2) & ":" & _ Mid(dtmInstallDate, 11, 2) & ":" & Mid(dtmInstallDate, _ 13, 2)) msgbox WMIDateStringToDate End Function

You might also like