Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried here to split the v2 value after 2 and increment by 1. but it is not update the value in my .bat file.Something is wrong in my code ?

What I have tried:

@echo on
Cd /d D:\

	setlocal enabledelayedexpansion
	set "file=new.bat"
	for /F "tokens=1,* delims==" %%i in ('findstr "V2=" new.bat') do (
    set "versionVar=%%~i"
    set "versionVal=%%~j"
	set "string=%versionVal:~2,1%"
	set "abc=ip"
    set /a sequence=%string% + 1
	echo %sequence%
	
	)
	for /f "tokens=1,*delims=]" %%i in ('type "%file%" ^| find /v /n "" ^& break^>%file%') do (
    set "line=%%j"
    if "!line!" == "!versionVar!=!versionVal!" set line=!versionVar!=!sequence!
    echo(!line!>>!file!
	)
	pause
Posted
Updated 7-Nov-22 5:28am

1 solution

Try with:
set /a "sequence=string+1"

See: Set - Environment Variable - Windows CMD - SS64.com[^]
 
Share this answer
 
v2
Comments
RickZeeland 8-Nov-22 2:41am    
Maybe the problem is in the second line: Cd /d D:\
Radha sharma 2022 8-Nov-22 4:19am    
@RickZeeland , Thanks it is working

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