Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Write to text file

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2740
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Write to text file
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Write to text file - 4/19/2005 9:34:44 AM   
  mike701024

 

Posts: 2
Score: 0
Joined: 4/19/2005
From:
Status: offline
I have txt files with hundreds of lines that I need to add (" to the front of each line and ") to the end of each line. Is there a way to script this?

Thanks,
 
 
Post #: 1
 
 Re: Write to text file - 4/19/2005 10:59:26 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Sure!

Modify the src variable to reflect the actual file name.
==============================================================================
Option Explicit
Dim src, fso, ts, temp, tempFile, output

src = "C:\temp\temp.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
tempFile = fso.BuildPath(fso.GetParentFolderName(src),fso.GetTempName)
Set output = fso.CreateTextFile(tempFile)
Set ts = fso.OpenTextFile(src)
Do Until ts.AtEndOfStream
temp = ts.ReadLine
temp = "(" & temp & ")"
output.WriteLine temp
Loop
ts.Close
output.Close
fso.DeleteFile src
fso.MoveFile tempFile, src

(in reply to mike701024)
 
 
Post #: 2
 
 Re: Write to text file - 4/19/2005 1:56:39 PM   
  mike701024

 

Posts: 2
Score: 0
Joined: 4/19/2005
From:
Status: offline
Thanks for your help.

(in reply to mike701024)
 
 
Post #: 3
 
 Re: Write to text file - 4/19/2005 1:59:04 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
No problem.

(in reply to mike701024)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Write to text file Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts