A VBScript for text search in .txt file.

  • Thread starter Thread starter Roomy
  • Start date Start date
R

Roomy

Guys,

I'd love if any of you can help me with this one.
I need a script that will take out the words Error,
Warning, and Aborted from a 12mb text file and into a new
text file after running the script.


Please.
 
* "Roomy said:
I need a script that will take out the words Error,
Warning, and Aborted from a 12mb text file and into a new
text file after running the script.

Notice that this is a VB.NET language group, but your question is
related to VBScript programming:

You may want to ask the question in this group:

<
 
Hi Roomy,

This is a VB.net group, that is not VB script.
Therefore I think you can better ask this too in a VB script newsgroup.

Most probably you don't get an answer here because the people who visit this
newsgroup are not very familair with VB script.
Although most of them knows a lot of it.

But your problem can be a hell of a job with VB.script.

When you want to use VB.net tell it than someone will probably help you.

Sorry that I could not help you

Cor
 
here's some old code from the cellar. it is meant to recurse through a dev
branch, find all the dlls and ocx files, create a dos batch that executes to
un/register them. all you have to do is modify it to your liking. you'll
need to use the file scripting object, open the file and and maybe instr$
for a text match. easy, breezy, beautiful cover girl!

next time, if you're not familiar w/ netiquette (a word overly used in a
very long thread today), please post questions to groups that have some
correlation to the context/language of your quandry.

hth,

steve


' ====== snip =======

Private mfso
Private mfd
Private mRegStream
Private mURegStream
Private mcstrHeader
Private mcstrErrText
Private mcstrFooter
Private mlngPtr
mcstrHeader = "@echo off" & vbCrLf & "cls" & vbCrLf & "echo [REG]..." &
vbCrLf & vbCrLf & "set has_err=0" & vbCrLf & "set errors=0" & vbCrLf & "set
e_text=0" & vbCrLf & vbCrLf
mcstrErrText = "if errorlevel=1 Set has_err=1" & vbCrLf & "if errorlevel=1
set errors=[SEQ]" & vbCrLf & "if errorlevel=0 set e_text=%errors%" & vbCrLf
& vbCrLf
mcstrFooter = "set e_text=Error, Line %e_text%" & vbCrLf & vbCrLf & "if
%has_err%==0 set e_text=No Errors" & vbCrLf & vbCrLf & "cls" & vbCrLf &
"echo [REG]!" & vbCrLf & "echo %e_text%" & vbCrLf & "pause"
mlngPtr = 0
mlnghFileReg = 1
mlnghFileUReg = 2


If MsgBox("Create Un/Register Batch Files?", vbYesNo, "Dll Auto-Register") =
vbYes Then
Set mfso = CreateObject("Scripting.FileSystemObject")
Set mfd = mfso.GetFolder("C:\")
Set mRegStream = mfd.CreateTextFile("Register.bat", True, False)
Set mURegStream = mfd.CreateTextFile("UnRegister.bat", True, False)
mRegStream.Write Replace(mcstrHeader, "[REG]", "Registering")
mURegStream.Write Replace(mcstrHeader, "[REG]", "Un-Registering")
SetDllRegText "C:\Your Project\Dev\"
mRegStream.Write Replace(mcstrFooter, "[REG]", "Registered")
mURegStream.Write Replace(mcstrFooter, "[REG]", "Un-Registered")
mRegStream.Close
mURegStream.Close
MsgBox "Done.", vbOKOnly, "Dll Auto-Register"
End If

Private Sub SetDllRegText(ByVal strSearchPath)
Dim dr
Dim sfld
Dim f
Dim strPrintData
If Right(strSearchPath, 1) <> "\" Then strSearchPath = strSearchPath &
"\"
Set dr = mfso.GetFolder(strSearchPath)
For Each f In dr.Files
If Right(LCase(f.Name), 4) = ".dll" Or Right(LCase(f.Name), 4) =
".ocx" Then
mlngPtr = mlngPtr + 1
strPrintData = Replace(mcstrErrText, "[SEQ]", mlngPtr)
mRegStream.Write "regsvr32.exe " & """" & strSearchPath & f.Name
& """ /s" & vbCrLf & strPrintData
mURegStream.Write "regsvr32.exe /u " & """" & strSearchPath &
f.Name & """ /s" & vbCrLf & strPrintData
End If
Next
If dr.SubFolders.Count Then
For Each sfld In dr.SubFolders
If Err.Number Then Exit For
SetDllRegText sfld.Path
Next
End If
End Sub
 
Roomy said:
Guys,

I'd love if any of you can help me with this one.
I need a script that will take out the words Error,
Warning, and Aborted from a 12mb text file and into a new
text file after running the script.

I had a similar problem the other day, and ended up using a brilliant
freeware utility called AutoIt.

Here is the download page http://www.computerhope.com/dutil.htm


I also made the mistake of asking the question the wrong group, so apologies
everyone for the original error, and persisting in this error with a
solution.
 
Hi Roomy,
I also made the mistake of asking the question the wrong group, so apologies
everyone for the original error, and persisting in this error with a
solution.

What is wrong with that

VB.net has a

Try
..................The one who has a problem
Catch
.................. Regulars in this group or all others
Finnaly
.................. You
End Try
:-))
Cor
 
* "z said:
I also made the mistake of asking the question the wrong group, so apologies
everyone for the original error, and persisting in this error with a
solution.

You don't need to apologize. Directing you to the right group was only
a hint for you to get a response in shorter time. You are welcome to
post your VB.NET related questions to this group.
 
* "Cor said:
What is wrong with that

VB.net has a

Try
.................The one who has a problem
Catch
................. Regulars in this group or all others
Finnaly
^^^^^^^

Nice typo.

;-)
 
lol. programmer to the end!

;^)


| Hi Roomy,
| > I also made the mistake of asking the question the wrong group, so
| apologies
| > everyone for the original error, and persisting in this error with a
| > solution.
|
| What is wrong with that
|
| VB.net has a
|
| Try
| .................The one who has a problem
| Catch
| ................. Regulars in this group or all others
| Finnaly
| ................. You
| End Try
| :-))
| Cor
|
|
 
Back
Top