Solved Batch file to increase version number in txt file

October 2, 2014 at 05:35:32
Specs: Windows 64
I have this exact line in a text file (among many other code lines).

_Version = "X.Y.ZZ alpha"--<<<<<<

where X Y and Z are numbers.

I want to make a batch file that will increase the last set of numbers (ZZ) by 1 whenever I open it

I would manually change the X and Y before ZZ reaches 99.

Thanks!

message edited by xelu


See More: Batch file to increase version number in txt file

Report •


✔ Best Answer
October 6, 2014 at 09:39:25
Depending on what other special characters might be lurking in the file, but wouldn't something like this work:

@echo off>temp & setlocal
for /f "tokens=* " %%a in (z) do (
set c=%%a
set a=!c:~0,11!
if /i "!a!" equ "_Version = " (call :zz) else (>>temp echo %%a)
)
type temp
move /y temp z
goto :eof


:zz
set x=!c:~11,5!
set b=!c:~16,2!
set d=!c:~18!
echo a !a!
echo b !b!
echo d !d!
set /a b=1!b!-100+1
echo b !b!
set b=0!b!
>>temp echo !a!!x!!b:~-2!!d!
goto :eof



#1
October 2, 2014 at 22:17:46
Is the relevant line this:

_Version = "X.Y.ZZ alpha"--<<<<<<

or is it simply this:

_Version = "X.Y.ZZ alpha"

=====================
M2 Golden-Triangle


Report •

#2
October 3, 2014 at 02:47:06
with the --<<<<<<

so it can be used as a delim if needed


Report •

#3
October 5, 2014 at 22:46:34
I don't see a way to do this because of the <<<<<<
And I don't think win64 we run debug.

Go to a prompt and run:

debug

You will get either:

C:\TEMP\-\10-02>debug
-

in which case type q and press ENTER.

Or you'll get:

'debug' is not recognized as an internal or external command,
operable program or batch file.

=====================
M2 Golden-Triangle


Report •

Related Solutions

#4
October 6, 2014 at 09:39:25
✔ Best Answer
Depending on what other special characters might be lurking in the file, but wouldn't something like this work:

@echo off>temp & setlocal
for /f "tokens=* " %%a in (z) do (
set c=%%a
set a=!c:~0,11!
if /i "!a!" equ "_Version = " (call :zz) else (>>temp echo %%a)
)
type temp
move /y temp z
goto :eof


:zz
set x=!c:~11,5!
set b=!c:~16,2!
set d=!c:~18!
echo a !a!
echo b !b!
echo d !d!
set /a b=1!b!-100+1
echo b !b!
set b=0!b!
>>temp echo !a!!x!!b:~-2!!d!
goto :eof


Report •


Ask Question