Writing a bat. Can I parse a token into characters?

djheater

Lifer
Mar 19, 2001
14,637
2
0
I've got a text file I need to parse a string from. I'm pretty goo at NT Shell scripting, and I can grab the token from the file... but in SOME, not all, cases there are two random characters before the information I want.

Is there any way to break it apart into individual characters? then I could massage it the way I need...

Any ideas appreciated.
 

KB

Diamond Member
Nov 8, 1999
5,406
389
126
Not exactly sure what you are trying to do, but I am pretty sure batch can't do it.


VBS script can read from a text file one line or one character at a time, which you can then do if...then checks

Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set FileStream = FSO.OpenTextFile(FileName)
Do until FileStream.AtEndOfStream
Dim charRet = FileStream.Read(1) 'read one char at a time
Loop


http://msdn.microsoft.com/library/defau...n-us/script56/html/jsobjtextstream.asp
 

GilletteCat

Member
Dec 28, 2001
181
0
0
Create a wsf file using, say, javascript:

If your "good" string always starts with the same known char's, then you don't need to break it up:

var strMyInitString = ........ (your captured string)
var strMyFinalString = strMyInitString.Slice(strMyInitString.IndexOf("...desired starting char's..."))

 

djheater

Lifer
Mar 19, 2001
14,637
2
0
Thanks for the responses guys... In asking around I discovered that XP up allows for environment variable editing... so I am able to take the left six characters using the following

%name:~-m% where m is the amount of characters starting from the left that you want...

I found this info in "WINDOWS XP Under the Hood"