Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Collating Data

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Collating Data
  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 >>
 Collating Data - 7/13/2005 9:00:44 PM   
  meatychi

 

Posts: 1
Score: 0
Joined: 7/13/2005
Status: offline
Hello to all!

I am totally new to VB scripting, so this question will probably be a breeze for someone on here to helpme with.

I have a number of files with data in that look like this:

[Registry Info]
csdversion=Service Pack 2
registeredorganisation=Company Name
registeredowner=POS Till
defaultdomainname=Location-BS
defaultusername=user

Can someone provide me with a script that will open all of these files and import them into a spreadshet with the csdversion, registeredorganisation, registeredowner....... as the column headers?

If someone could help me with this task I would be eternally grateful!

Thanks

meatychi ( newbee! )
 
 
Post #: 1
 
 RE: Collating Data - 7/15/2005 7:45:14 AM   
  MAK

 

Posts: 5
Score: 0
Joined: 7/15/2005
Status: offline
vbscript


Set objArgs = WScript.Arguments
inputfile=objArgs(0)
Set iFSO = CreateObject("Scripting.FilesyStemObject")
Set oFSO = CreateObject("Scripting.FilesyStemObject")
Set ifile = iFSO.OpenTextFile(inputfile) 
text2=""
Do until ifile.AtEndOfLine
text1= ifile.ReadLine
if left(text1,23)="registeredorganisation=" then
a=replace(text1,"registeredorganisation=","")
end if
if left(text1,16)="registeredowner=" then
b=replace(text1,"registeredowner=","")
end if
if left(text1,18)="defaultdomainname=" then
c=replace(text1,"defaultdomainname=","")
end if
if left(text1,16)="defaultusername=" then
d=replace(text1,"defaultusername=","")
end if
loop
wscript.echo a & "," & b & "," & c & "," & d


Usage:
 
cscript/nologo readfile.vbs a.txt

result:
Company Name ,POS Till ,Location-BS ,user


You can call this script many times for every files using a FOR loop in a batch file. or use vbscript to loop through all the files in  the folder.

(in reply to meatychi)
 
 
Post #: 2
 
 
 
  

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 >> Collating Data 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