Good Day,

How would you code in VBScript to read the content of multiple HTML files into an array? Please observe the below sample and modify as necessary. My requirement is read multiple files by extension and not simply specify a single file.

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\scripts\servers and services.txt", ForReading)

Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , ",")
Wscript.Echo "Server name: " & arrServiceList(0)
For i = 1 to Ubound(arrServiceList)
Wscript.Echo "Service: " & arrServiceList(i)
Next
Loop


Regards,
Keith

Here is my latest VBScript. Please examine my code and make any recommendations for improvement that you believe warranted. I really need your feedback ASAP!

Option Explicit
'On Error Resume Next

Dim objFSO, objFolder, objFile, objFiles, objNewFile
Dim Item, strNextLine

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\RATLREPO\RMT\MRTU\Pub")
Set objFiles = objFolder.Files
Set objNewFile = objFSO.OpenTextFile("C:\RATLREPO\RMT\MRTU\Output\New_file.html", 2, True)

For Each Item In objFiles
If LCase(Right(Item.Name, 5)) = ".html" Or LCase(Right(Item.Name, 4)) = ".htm" Then
Set objFile = objFSO.OpenTextFile(item.Path, 1, False)

Do Until objFile.AtEndOfStream
strNextLine = objFile.ReadLine
objNewFile.WriteLine(strNextLine)
Loop
End If
Next


Best Regards,
Keith

Good Day,

How would you code in VBScript to read the content of multiple HTML files into an array? Please observe the below sample and modify as necessary. My requirement is read multiple files by extension and not simply specify a single file.

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\scripts\servers and services.txt", ForReading)

Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , ",")
Wscript.Echo "Server name: " & arrServiceList(0)
For i = 1 to Ubound(arrServiceList)
Wscript.Echo "Service: " & arrServiceList(i)
Next
Loop


Regards,
Keith

Good Day,

Through the public domain, I have been able to develop a VBScript for my customer requirement in support of IBM Rational Manual Tester and published test scripts in HTML. If you would like to have a copy of my script. Please post to this forum.

Regards,
Keith

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.