Click here to Skip to main content
15,606,012 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The content be like :
#define test 20

I want to extract 20 from the whole string. How I do it ?

What I have tried:

setlocal EnableDelayedExpansion
cd /d D:\
for /F "tokens=1,* delims= " %%i in ('findstr "test  " abc.h') do (
    set "versionVar=%%~i"
    set "versionVal=%%~j" 
	set test=%versionVal:~4,5%
	set /a "string=%%~j+1"
I tried to search test string from file. Try to get 20 from the .h file in versionval variable and also try to get #define test in variable versionvar.
Updated 17-Nov-22 19:56pm

1 solution

Why are you giving yourself so much trouble by doing it all in batch file language, when it's pretty trivial to do in any "full fat" programming language? And since you are trying to process C files, why not code it in C and use the app in a batch file?

You've been trying to play with this for what, a month now and still have problems - you could have written code in almost any language to do each of the tasks you seem to be having problems with in what, an hour each at most?

Use the most appropriate language, not just batch commands!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900