Intranet Journal

Go Back   IT Management Forum > Intranet Journal

Intranet Journal The new discussion forum for Intranet Journal readers. Leave comments and questions for IJ authors. Suggest story ideas and provide feedback.

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 06-04-2006, 02:51 AM
blakeph blakeph is offline
Registered User
 
Join Date: Jun 2006
Posts: 2
reading text file using VBSCRIPT

hello everyone!

i have a VBSCRIPT that will read the last 6 entries (from bottom to top) of a text file, and then would save the result into a separate text file called "result.txt", and the code look like this:
PHP Code:
Dim arrFileLines()
i = 0
Set objFSO
= CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("d:\backup\test.txt", 1)

' create the output file here
Set objoutputFile = objFSO.CreateTextFile("d:\backup\result.txt")

Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close
For l = Ubound(arrFileLines)-5 to Ubound(arrFileLines)

'
write the output to the file
objoutputFile
.writeline arrFileLines(l)
Next

'Close the output file
objoutputFile.close
am trying to modify the code to read only the second line (from bottom to top) of the text file and then save it to separate text file, but i could'nt do it, any help would be appreciated. thanks!
Reply With Quote
  #2 (permalink)  
Old 06-04-2006, 09:39 AM
JPnyc JPnyc is offline
Administrator
 
Join Date: Jan 2005
Posts: 424
Well I think you should be able to reference it with the len function, i.e.:

len(arrFileLines()) - 2

Basically I think that will give you the 2nd to last line
__________________
Datamation Online Community Manager
Reply With Quote
  #3 (permalink)  
Old 06-08-2006, 03:31 PM
blakeph blakeph is offline
Registered User
 
Join Date: Jun 2006
Posts: 2
thanks JPnyc, i got it using your suggestions.
Reply With Quote
  #4 (permalink)  
Old 06-08-2006, 03:43 PM
JPnyc JPnyc is offline
Administrator
 
Join Date: Jan 2005
Posts: 424
Cool! I'm on a roll with vbscript and I never studied it
__________________
Datamation Online Community Manager
Reply With Quote
  #5 (permalink)  
Old 12-03-2009, 04:47 AM
keep smilling keep smilling is offline
Registered User
 
Join Date: Dec 2009
Posts: 1
i would like to know how to parse a rar file into .csv file using vbscript
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 09:23 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0