Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.
Dim fso, startFolder, OlderThanDate Dim strFilename, strPath Set fso = CreateObject("Scripting.FileSystemObject") strFilename = "urgent.txt" OlderThanDate = DateAdd("d", -60, Date) ' 60 days (adjust as necessary) set objFSO = CreateObject("Scripting.FileSystemObject") if objFSO.FileExists(strFilename) Then set objFile = objFSO.GetFile(strFilename) Dim TextStream Set TextStream = objFile.OpenAsTextStream(1,0) Dim Line,i Do While Not TextStream.AtEndOfStream strPath = trim(TextStream.readline) DeleteOldFiles strPath, OlderThanDate Loop Set TextStream = nothing Else Msgbox "Input File not found" End If Msgbox "Old Backup files have been deleted...Done !!" Function DeleteOldFiles(folderName, BeforeDate) Dim folder, file, fileCollection, folderCollection, subFolder Set folder = fso.GetFolder(folderName) Set fileCollection = folder.Files For Each file In fileCollection If file.DateLastModified < BeforeDate Then fso.DeleteFile(file.Path) End If Next Set folderCollection = folder.SubFolders For Each subFolder In folderCollection DeleteOldFiles subFolder.Path, BeforeDate Next End Function
|How to pass URL parameters to VBS Script File||12||68|
|delete a folder ever 5 minutes||6||47|
|Disconnecting old WiFi and connecting to the new WiFi through scripting and GPO||8||26|
|Messed up my code||6||0|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
19 Experts available now in Live!