Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send the first text line (row) to RunPro.vbs to line...Etc. (in .vbs)

Status
Not open for further replies.

Lucas90

Vendor
Aug 30, 2014
1
0
0
RO
||||(Here is picture with what I want to do, the script)


C:\0001.txt Send the first text line (row) to RunPro.vbs to line, after send | delete\remove first line in C:\0001.txt
C:\0002.txt Send the first text line (row) to RunPro.vbs to line, after send | delete\remove first line in C:\0002.txt
C:\0003.txt Send the first text line (row) to RunPro.vbs to line, after send | delete\remove first line in C:\0003.txt
C:\0004.txt Send the first text line (row) to RunPro.vbs to line, after send | delete\remove first line in C:\0004.txt

<<<===| Please look here)

I need your help Thank you.
 
What do you have so far?

What you will want to do is read the entire file into an array. You can then reference the first line as element 0. Then write the contents of element 1 to the UBound of the array back to your file to remove the first line.

Code:
Set oFSO = CreateObject("Scripting.FileSystemObject")
'open the data file
Set oTextStream = oFSO.OpenTextFile("c:\temp\file1.txt")
'make an array from the data file
lineArray = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close

FirstLine = lineArray(0)

For x = 1 To UBound(lineArray)
	AllTheRest = AllTheRest & lineArray(x) & vbCrLf
Next 

WScript.Echo FirstLine
WScript.Echo AllTheRest

Make sure your file is in ANSI format and not Unicode.

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top