Code Script .co.uk

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Filter Text Lines Containing
 

Vbscript / Text Processing / Filter Text Lines Containing

Examine each line in a file and output it to another file if a specific string is contained within the line of text.


Set objFSO = CreateObject("Scripting.FileSystemObject")

strFind = "keep me"

Set objInFile = objFSO.OpenTextFile("C:input.txt", 1)
Set objOutFile = objFSO.OpenTextFile("C:output.txt", 8, True)


Do Until objInFile.AtEndOfStream

strLine = objInFile.Readline

intPos = inStr(strLine, strFind)

'Remove NOT below for filter: If does not contain...
If NOT intPos = 0 Then

objOutFile.WriteLine strLine

End If

Loop





Please note that a disclaimer applies to any code on this page.
 
   Actions
  Go Back
  Bookmark
  Print Page


   Menu
 
- Links
- Reference
- Script Editors
- Tutorials
- Vbscript
     - Active Directory
     - Exchange
     - Files And Folders
     - General
     - Ms Office
     - Operating System
     - Processes And Services
     - Text Processing
          - Filter Text Lines Containing
          - Get Html Tag Content
          - Merge File Contents
          - Read Xml File
     - User Interaction
     - Web Servers