Scan 1000 line text file and copy text inside quotes on each line to a new text file

Posted on 2009-05-22
Medium Priority
Last Modified: 2012-05-07
I have a file that has 1000+ lines of text, and I need only the text which is inside quotes.

text text text text

text text text text    "copy this to new file"
text text text text    "also copy this"
text text "everything in quotes should be copied to a new file"

I am stumped on how to accomplish this in vbs.

Any help would be appreciated!
Question by:DougR73
  • 2
LVL 67

Accepted Solution

sirbounty earned 2000 total points
ID: 24451123
This should do it..
 Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOut : Set objOut = objFSO.CreateTextFile("F:\NewFile.txt")
arrData = Split(objFSO.OpenTextFile("F:\Test.txt").ReadAll, vbNewLine)
For Each strData in arrData
  If InstrRev(strData, chr(34)) > 0 Then
    strStart = Instr(strData, chr(34)) + 1
    strStop = InstrRev(strData, chr(34))
    strNewData = Mid(strData, strStart, strStop - strStart)
    objOut.WriteLine strNewData
  End If

Open in new window

LVL 67

Expert Comment

ID: 24451582
Glad I could help - thanx for the grade! :^)

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question