Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.
' Autor: Fernando Inácio ' Date: 02-03-2006 ' ' Description : Deletes files of a certain date and time. ' It also generates an output of the total number of deleted ' files and creates a log file. strDateTime = "16-02-2006" strPath = "D:\G\scanner\UAT" strDatediff= " " intFileCount = 0 strComputer = "." Dim logFile Set objFSO = CreateObject("Scripting.FileSystemObject") Set logFile= objFSO.CreateTextFile(strPath & "\deleteFiles.log", True) Set Folder = objFSO.GetFolder(strPath) logFile.Write "Directory Name: " & strPath & VbCrLf logFile.Write "Date: " & Now() & VbCrLf & VbCrLf For Each file In Folder.Files if DateDiff("d", File.DateLastModified, Now) >= 7 Then intFileCount = intFileCount + 1 logFile.Write "File: " & File.name & vbTab & vbTab & File.DateLastModified & VbCrLf logFile.Write CRLF objFSO.DeleteFile(strPath & "\" & file.name) End If Next If intFileCount = 0 Then MsgBox "No files to delete!" Else MsgBox intFileCount & " files deleted!" End If logFile.Write CRLF logFile.Write intFileCount & " File Deleted." logFile.Close Set lofFile = Nothing Set objFSO = Nothing Set Folder = Nothing
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|VB Script: Drill down in order to get the most recent folder in a Root folder and most recent file in the folder||3||38|
|HTA with vb script to restart specific windows services||12||113|
|What's the best robocopy cmd to copy file only if the file has changed and not existed.||14||41|
|Move files based on file names?||8||67|
Join the community of 500,000 technology professionals and ask your questions.