Home > DeveloperSection > Forums > Break down sections in a text file using vbscript
Samuel Fernandes
Samuel Fernandes

Total Post:156

Points:1096
Posted on    June-20-2013 1:54 AM

 VB Script VB Script 
Ratings:


 1 Reply(s)
 829  View(s)
Rate this:
Hi Expert, 

I have a file which is in this format

name.css  value
name.js  value 

I want to break this down and create strings which will be in this format string1 = "c:\" + value + name + extension(css or js) can someone please tell me how to do this in vbscript.

So far I am looking to break this into dictionary and then loop through and creating new dim objects which loops through the whole file and creates values but not getting it right.Any help is very much appreciated.

Any help would be amazing thank you!


Vijay Shukla

Total Post:100

Points:700
Posted on    June-20-2013 5:29 AM

Hi,

Try this:

Set fso = CreateObject("Scripting.FileSystemObject")

Set re = New RegExp
re.Pattern = "\s+"
re.Global  = True

Set f = fso.OpenTextFile("C:\your\input.txt")
Do Until f.AtEndOfStream
  tokens = Split(Trim(re.Replace(f.ReadLine, " ")))
  WScript.Echo "C:\" & tokens(1) & tokens(0)
Loop
f.Close

Don't want to miss updates? Please click the below button!

Follow MindStick