This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!
Option Explicit Const ForReading = 1 Const ForWriting = 2 Dim objFSO Dim fld Dim fil Dim strFile Set objFSO = CreateObject("Scripting.FileSystemObject") 'Set the directory you are looking at Set fld = objFSO.GetFolder("C:\tempdirectory\findit") 'Loop through each file in the folder For Each fil in fld.Files strFile = lcase(fil.path) 'If it is a text file send it off for editing If Right(strFile,3) = "txt" Then DeleteLines strFile, "AT6666T6" End If Next 'Clean up Set fld = Nothing Set objFSO = Nothing Private Sub DeleteLines(sFile, sSearch) Dim objFile Dim strLine Dim strNewContents Set objFile = objFSO.OpenTextFile(sFile, ForReading) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine If InStr(strLine, sSearch) > 0 Then strNewContents = strNewContents & strLine & vbCrLf End If Loop objFile.Close Set objFile = objFSO.OpenTextFile(sFile, ForWriting) objFile.Write strNewContents objFile.Close Set objFile = Nothing End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.