I am looking for a batch file script that can get me previous available version from a list of versions string.
Example: ListOfVersion: "16.5.0.0,16.5.1.0,16.5.2.0,16.6.0.0,17.2.0.0" CurrentVersion : "16.5.1.4"
Above are the available values, now I want a bat file logic to get previous available versions from the list as below
PreviousAvailableVersion : "16.5.1.0"
Thanks for the answers.
More Examples "16.5.0.0,16.5.1.0,16.5.2.0,16.6.0.0,17.2.0.0"
IF "16.5.0.1" is installed version then I am expecting prev version to be 16.5.0.0 IF "16.6.1.1" is installed version then I am expecting prev version to be 16.6.0.0
Here is some idea I thought of.. we can have some logic to loop and decrement current version and compare with that list and matching result should be the answer.
Many thanks
The batch file below produces the expected result under following conditions:
16.5.0.0,17.2.0.0,16.5.1.0,16.6.0.0,16.5.2.0.16.5.020.08. The Windows Command Processor interprets numbers with a leading0as octal numbers.020is interpreted therefore as decimal number16and08as decimal number0because of the digits8and9are invalid in an octal number and zero is used in this error case.The batch file for determining the previous version is:
The batch file can be run from within a command prompt window with a version string as first argument for easy testing it without changing any line in the batch file.
To understand the commands used and how they work, open a command prompt window, execute there the following commands, and read the displayed help pages for each command, entirely and carefully.
call /?... explains%~1echo /?endlocal /?for /?goto /?if /?set /?setlocal /?See also:
&as used in the batch file above multiple times.