How to extract version number in a Windows batch file?

后端 未结 3 1935
小鲜肉
小鲜肉 2021-01-07 00:23

I need to extract the Major , Minor and Revision numbers from a string and to achieve this I\'m trying to split a string in a batch file using a \'.\' character as the delim

3条回答
  •  清歌不尽
    2021-01-07 00:37

    Not have enough reputation to comment. Posting an answer instead :)

    There's a helpful resource: http://ss64.com/nt/syntax-substring.html

    SET _test=123456789abcdef0
    
    ::Skip 7 characters and then extract the next 5
    
     SET _result=%_test:~7,5%
     ECHO %_result%          =89abc
    

    Use this approach to extract substrings from the string as you want.

    UPDATE:

    Get position of a character in a string

    As you get the dot position, you can use the above described approach to extract necessary parts from the input string.

提交回复
热议问题