MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
Dim fso, objShell '=================================== 'Start of Sub-routine Sub fFIND(oFolder) DIM oFile DIM oSdate, oCdate,objFile 'Look at each file in the current folder Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.GetFile((oFile.Name), "C:\myfolder\Log20*") For Each oFile in oFolder.Files 'Check for a file of the format *LOG20*.TXT if inStr(uCase(oFile.Name), "LOG20") > 0 and uCase(right(oFile.name,4)) = ".TXT" then oSdate = DateValue(oFile.DateLastModified) oCdate = DateDiff("d", oSdate, Date) 'Log and delete *LOG20*.TXT files older than 15 days if oCdate >= 15 And objFSO.size < 2 Then Call LoggerF(oFile.Path) oFile.Delete True End if end If Next End Sub '====================================== '===================== 'Write Log Sub Sub LoggerF(fPath) DIM oFSO, oStream, oFile, WshNetwork On Error Resume Next Set WshNetwork = WScript.CreateObject("WScript.Network") Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFile = oFSO.GetFile("CleanupLog.txt") Set oStream = oFile.OpenAsTextStream(8, 0) oStream.Write VbCrLf & Ucase(WshNetwork.UserName) & " deleted " & fPath & " at " & Now oStream.Close set oStream = Nothing set oFile = Nothing set oFSO = Nothing set WshNetwork = Nothing End Sub '===================== on error resume Next Set fso = WScript.CreateObject("Scripting.FileSystemObject") Set objShell = Wscript.CreateObject("Wscript.Shell") 'Call the Sub-routine that searches and deletes the files fFIND fso.GetFolder("C:\myfolder") objShell.LogEvent EVENT_SUCCESS, "Log file cleanup finished at " & date Wscript.Quit set objShell = Nothing set fso = Nothing
|SSIS 2010 Convert to SSIS 2013 On Different Box||3||58|
|Visual Studio search word table and return Cell index||8||60|
|VB Script to add site to Java Exception List||4||74|
|Sending Attachment via CDO||3||68|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
10 Experts available now in Live!