Simple Version Number Updating in Batch File for Build Scripts


On windows, platform, the resource files (*.rc) can be used to define version and file information. The *.rc are compiled to *.res (binary) using e.g. brcc32.exe (the delphi resource compiler). The *.rc files are text based meaning that you can do version control on them.

In [this article], we talk about the method to store file information in the resource file for delphi projects. So one of the basic requirement is to auto-increment the build number (the right-most number in the version string). The simplest method to achieve this is to have a text file storing the latest building number, e.g. ver.txt.

Then we can have a IncBuild.bat which does this job easily.

@ech off
set /p Build=<ver.txt
set /a Build=%Build%+1
echo %Build%>ver.txt

Each time IncBuild.bat is executed, the number string is loaded to variable Build and incremented by one using set /a (for arithmetic operations). Last, the variable is written back to ver.txt.

Using set /p asks for input from the keyboard, however, you can redirect the file content to the variable using < redirection.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
273 words
Last Post: How to Store File Information (Version) in Resource File for Delphi Projects
Next Post: How to Make First Letter in First Paragraph Big in WordPress (CSS) articles?

The Permanent URL is: Simple Version Number Updating in Batch File for Build Scripts

Leave a Reply