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.
' 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
|VBscript/Batch file: copy files/folders based on a csv file||15||82|
|CMD BAT file script SET / Delayed Expansion issue in FOR/DO construct||4||39|
|How can I save all open docs into a given folder||12||113|
|problems with mysql ODBC Connector and vbscript||4||31|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
12 Experts available now in Live!