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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove a carriage return from a text document

Status
Not open for further replies.

collierd

MIS
Dec 19, 2001
509
DE
Hello

Does anybody know if the following is possible:

I have a number of text files generated monthly (i.e. A123450001.TXT)
Each of these text files are generated from a data extract into text format
Problem is, it keeps adding an extra carriage return at the end
Can vbscript be used to remove the last line only from a txt file?
If so, how

Thanks

Damian.
 
Yes, you can do it but it's a little "heavy" :
- rename your text file as .old
- open it as textstream (with filesystem object's method "OpenTextFile" wich returns a textStream object).
- Create a new text file (with .old's original name) with the filesystem object's method "CreateTextFile".
- read all lines form .old to write them to new .txt using "readLine" and "WriteLine" methods of TextStream object.
- "Forget" to write last read line. Water is not bad as long as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top