Click here for important information about

parse a string

Microsoft Windows xp professional w/serv...
August 12, 2010 at 06:55:21
Specs: Windows XP
I want to write a batch file which I can run against a text file which will capture the number in front of a colon on a line in the text file.

This is an example of the line in the file-
206: ProfileImagePath Reg_Expand_sz

I want to capture the number in front of the : in a variable or text file. The number varies in length.

See More: parse a string

August 12, 2010 at 10:29:41
Is there just ONE line with a number followed by a colon?

Helping others achieve escape felicity


Report •

August 12, 2010 at 11:38:06
Yes. I've managed to parse it out and put the line in a text file. The problem is that the number in front of the colon might be anywhere from 1 -5 digits long.

Report •

August 12, 2010 at 21:48:31
@echo off
for /f "tokens=1 delims=:" %%a in (string.txt) do ( set code=%%a )
echo %code%

Report •

Related Solutions

August 13, 2010 at 05:35:45
Great! This is much nicer than how I was doing it

Report •

Ask Question