Increment the version and current date in .ver file

Hi All,

I have the version.ver file and it looks like

[version]

BuildDates=2014.10.01

Script=01

MainVersion=1.00.00.00:01

I want to increment the values and current date if i trigger the build using batch script. The output i need is like this

BuildDates=yy.mm.dd (current date)

Script=02

MainVersion=1.00.00.00:02

Thanks in advance

October 10th, 2014 2:24am

Sorry, we do not write scripts on request but we gladly help you with your own script.
Free Windows Admin Tool Kit Click here and download it now
October 10th, 2014 4:56am

Thanks for your reply. This is my script

@echo off>newfile&setlocal enabledelayedexpansion
:: set up your date here. It probably won't match my format so you'll need to adapt:
set dt=%date:~10,4%.%date:~7,2%.%date:~4,2%
for /f "skip=2 tokens=2,3 delims==:" %%a in ("filename") do (
set v= %%b
set v= !v: 0=!
set /a v+=1
set v=0!v!
set v=!v:~-2!
>>newfile echo SCRIPT=!v!
>>newfile echo BuildDates=%dt%
>>newfile echo MajorVersion=%%a:!v!
goto :aa
)
:aa
more +3 "filename" >> newfile
del "filename"
ren newfile "filename"

Before execute the script my file will be look like:

version]

BuildDates=date

Script=09

MainVersion=3.00.00.00:09

after executing i am getting the output value as

BuildDates=date

Script=01

MainVersion=19:01

MainVersion=3.00.00.00:09



October 10th, 2014 5:44am

You can use the script below to generate your script version and your main version. You still need to deal with leading zeros. After generating the variables you could use a number of echo commands to completely regenerate the file. This saves you the trouble of deleting and renaming the file.

@echo off
SetLocal EnableDelayedExpansion
set dt=%date:~10,4%.%date:~7,2%.%date:~4,2%
set Pass=1

for /f "skip=2 tokens=2 delims==" %%a in ('type test.txt') do (
  call :Sub!Pass! %%a
  set /a Pass=!Pass! + 1
  if !Pass! GTR 2 goto Exit
)

:Exit
rem more +3 "filename" >> newfile
rem del "filename"
rem ren newfile "filename"
goto :eof

Process the script version
:sub1
set /a Script=%1+1
echo Script=%Script%
goto :eof

Process the main version
:sub2
for /F "tokens=1,2 delims=:" %%p in ('echo %1') do set Prefix=%%p& set /a Suffix=%%q + 1
echo MainVersion=%Prefix%:%Suffix%

Free Windows Admin Tool Kit Click here and download it now
October 10th, 2014 7:09am

You can use the script below to generate your script version and your main version. You still need to deal with leading zeros. After generating the variables you could use a number of echo commands to completely regenerate the file. This saves you the trouble of deleting and renaming the file.

@echo off
SetLocal EnableDelayedExpansion
set dt=%date:~10,4%.%date:~7,2%.%date:~4,2%
set Pass=1

for /f "skip=2 tokens=2 delims==" %%a in ('type test.txt') do (
  call :Sub!Pass! %%a
  set /a Pass=!Pass! + 1
  if !Pass! GTR 2 goto Exit
)

:Exit
rem more +3 "filename" >> newfile
rem del "filename"
rem ren newfile "filename"
goto :eof

Process the script version
:sub1
set /a Script=%1+1
echo Script=%Script%
goto :eof

Process the main version
:sub2
for /F "tokens=1,2 delims=:" %%p in ('echo %1') do set Prefix=%%p& set /a Suffix=%%q + 1
echo MainVersion=%Prefix%:%Suffix%

October 10th, 2014 1:56pm

I tried with your script while executing the batch file its updating in command prompt but its not update the script and mainversion change in the version.ver file.

thanks in advance. 

Free Windows Admin Tool Kit Click here and download it now
October 13th, 2014 2:07am

I tried with your script while executing the batch file its updating in command prompt but its not update the script and mainversion change in the version.ver file.


My script gives you the main elements to solve your problem. It is not a turn-key solution. Your task is to put the pieces together and generate the new file. Feel free to ask if you need clarification on some of its elements.
October 13th, 2014 4:01am

Since you file is an INI file you would want to use INI technology.  Batch is not good at dates or at editing files.  It is actually pretty much obsolete.

See this for tools to edit INI files directly: https://gallery.technet.microsoft.com/Edit-old-fashioned-INI-f8fbc067

Free Windows Admin Tool Kit Click here and download it now
October 13th, 2014 8:47am

I tried with your script while executing the batch file its updating in command prompt but its not update the script and mainversion change in the version.ver file.

thanks in advance. 

October 13th, 2014 8:59am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics