How can I read a specific line (line # 750) and then save it to a
separate file?

Re: Read Line & Save to separate file by trading_jacks

trading_jacks
Mon Oct 16 11:34:23 CDT 2006

This basically just loops through each line, until it reaches the
required line and then prints it and quits the script. There may be a
more effiecient way to do this, but this is all I know.


************************************************

On Error Resume Next

Dim filesys, demofolder, subfol, folcoll, i

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("\\niles\wsutil\complist.txt",
1)

strText = objTextFile.ReadAll
objTextFile.Close

arrComputers = Split(strText, vbCrLf)

Set filesys = CreateObject("Scripting.FileSystemObject")
Set TextFile = filesys.OpenTextFile("\\niles\wsutil\testinfo.txt", 8,
True)

i = 1

For Each strComputer in arrComputers

If i = 750 Then

TextFile.WriteLine strComputer
wscript.quit

End If

i = i +1

Next


Epoh Rio wrote:
> How can I read a specific line (line # 750) and then save it to a
> separate file?


Re: Read Line & Save to separate file by DiGiTAL

DiGiTAL
Mon Oct 16 13:23:47 CDT 2006

This is an easy way to pick out a specific numbered line from a file:

[code]
Dim oFile, oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile("c:\dev\test.txt",1)
Dim i
For i = 1 To 5
oFile.SkipLine
Next
WScript.Echo oFile.ReadLine 'This will print line 6
[/code]


---
Life is all about ass; you're either covering it, laughing it off,
kicking it, kissing it, busting it, trying to get a piece of it,
behaving like one, or living with one!

*** Sent via Developersdex http://www.developersdex.com ***

Re: Read Line & Save to separate file by Epoh

Epoh
Tue Oct 17 08:58:32 CDT 2006

Thank you both for your valuable post.


Re: Read Line & Save to separate file by Epoh

Epoh
Wed Oct 18 09:22:30 CDT 2006

RG8geW91IGtub3cgd2h5IEkgYW0gZ2V0dGluZyB0aGUgZm9sbG93aW5nIG91dHB1dCB3aGVuIHRy
eWluZyB0byByZWFkCm9uZSBmaWxlIGFuZCBzYXZlCm9uZSBsaW5lIGZyb20gdGhhdCBmaWxlIHRv
IGFub3RoZXIgZmlsZS4KCk5vdGU6IFRoaXMgb25seSBvY2N1cnMgYWZ0ZXIgdGhlIGZpbGUgaGFz
IGJlZW4gY3JlYXRlZC4gV2hlbiB0aGUgZmlsZQppcyBjcmVhdGVkLCBpdCBzYXZlcyB0aGUgbGlu
ZSAoNzEpIHRvIHRoZSBvdGhlciBmaWxlIHdpdGhvdXQgYSBwcm9ibGVtLgoKCldoZW4gSSBnbyB0
byBzYXZlIGFub3RoZXIgbGluZSAoNzUpIGl0IGFwcGVuZHMgdGhlIGZvbGxvd2luZyB0ZXh0IHRv
CnRoZSBmaWxlOgoKCuKxr+K4t+K4sOK4sOKwseK1mOK0suKwrOKwrOKwrOKxr+K4t+K4sOK4sOKw
seK1mOK0suKwrOKwrOKwrOKxr+K4t+K4sOK4sOKwseK1mOK0suKwrOKwrOKwrOKxr+K4t+K4sOK4
sOKwseK1mOK0suKwrOKwrOKwrAo=