0
I need to extract the version number from this C# source line using MSDOS batch file:
public const int major_version = 2;
My attempt:
:: Extract the number-token from the major version string.
:: The number-token has a semicolon appended.
for /F "tokens=6" %%a in ( str_Major_REV) do set number_token=%%a
This results in the variable number_token as 2;.
How can I remove the ';'?
{The ';' is used as a line separator by the delims parameter.}
Background:
The batch file is run by Jenkins build server. I want the batch file to:
- Extract the number.
- Increment the number and save as environment / batch file variable.
- Replace the original number with the incremented number.
- Use the number in a folder name.
- Use the number in a Code Management System version/label.
Items 4 and 5 are reasons I need the semicolon removed from the number token.
Environment
Windows server 2008
1(1)
delimscontaining semicolon works fine for me on Vista, which should be the same as 2008, and is not a 'line separator' (2) To remove the last character%number_token:~0,-1%(3) To remove semicolon anywhere%number_token:;=%– dave_thompson_085 – 2018-05-04T05:01:27.357A much easier way is a for loop
for %%A in (%str_Major_Rev%) do @set "number_token=%%A"Space, semocolon, comma, tab are all argument seperators. The loop wil set all items, but the last will stay. – LotPings – 2018-05-04T08:37:41.073