Hi everyone,
I am trying to read a file line by line but my script is just not cooperating. Can anyone please point out what I am missing?
Here's what I have:
'Option Explicit
Const INPUT_FILE_NAME = "C:\scripts\wmi\testers\XPLibrarySongList.txt"
Const FOR_READING = 1
On Error Resume Next
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Dim objFSO,objFile,strSongLine
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)
Do Until objFile.AtEndOfStream
strSongLine = objFile.ReadLine
If Err.Number <> 0 Then
Wscript.Echo strSongLine & " " & Err.Description & " " & Err.Number
Err.Clear
Else
wscript.Echo "Found " & strSongLine
End if
' Wscript.Echo strSongLine
' strSongTitle = Left(strSongLine, 45)
' Trim(strSongTitle)
' If Err.Number <> 0 Then
' Wscript.Echo strSongTitle & " " & Err.Description & " " & Err.Number
' Err.Clear
' Else
' wscript.Echo "Editing description field for " & strSongTitle
'
' End if
Loop
objFile.Close
When I run the script all I get is the word Found but not the rest of the line of text. Each line in the text file is a little over 200 characters wide.
Thanks in advance for your help
jazzfan
I am trying to read a file line by line but my script is just not cooperating. Can anyone please point out what I am missing?
Here's what I have:
'Option Explicit
Const INPUT_FILE_NAME = "C:\scripts\wmi\testers\XPLibrarySongList.txt"
Const FOR_READING = 1
On Error Resume Next
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Dim objFSO,objFile,strSongLine
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)
Do Until objFile.AtEndOfStream
strSongLine = objFile.ReadLine
If Err.Number <> 0 Then
Wscript.Echo strSongLine & " " & Err.Description & " " & Err.Number
Err.Clear
Else
wscript.Echo "Found " & strSongLine
End if
' Wscript.Echo strSongLine
' strSongTitle = Left(strSongLine, 45)
' Trim(strSongTitle)
' If Err.Number <> 0 Then
' Wscript.Echo strSongTitle & " " & Err.Description & " " & Err.Number
' Err.Clear
' Else
' wscript.Echo "Editing description field for " & strSongTitle
'
' End if
Loop
objFile.Close
When I run the script all I get is the word Found but not the rest of the line of text. Each line in the text file is a little over 200 characters wide.
Thanks in advance for your help
jazzfan