JSP
JSP

Reputation: 587

Issue while parsing the output in batch file

Can anyone please suggest me how can I get the value of 9 from the below output.

"Version

"9.0.56336

I know that we need to parse the output and get that value. But, am not succeded to get that.

Thanks In Advance.

Upvotes: 0

Views: 38

Answers (1)

Magoo
Magoo

Reputation: 80203

@ECHO OFF
SETLOCAL
SET "fine="9.0.56336"
ECHO %fine%
SET "fine=%fine:"=%"
ECHO %fine%
FOR /f "delims=." %%a IN ("%fine%") DO SET "fine=%%a"
ECHO %fine%

GOTO :EOF

Your ...set fine="%%%a" echo fine:%fine%

should be on two separate lines

...set fine="%%a"
echo fine:%fine% 

and there should be two, not three %s

This does set fine to the last line (I believe - haven't got the same installation, so I can't test it)

If you indeed have "9.0.56336 as your data content, then the above processing should get the 9.

Upvotes: 1

Related Questions