2

Here is my sample batch file code and I really don't know what it does.

set TEMPRPSW=%RPSW_VERSION% set RELVER=%TEMPRPSW:~0,4% set RELVER=%RELVER:.=% if %RELVER% GEQ 30 goto :eof 

Please give me a working sample.

3
  • 3
    Type set /? into a command prompt window and read the help message very carefully; you will find the description of such syntax intended to expand substrings... Commented Sep 18, 2018 at 10:25
  • Great! Very helpful. :) Commented Sep 18, 2018 at 10:27
  • 1
    Possible duplicate of what does it mean batch set variable=%variable:~1% Commented Sep 18, 2018 at 11:33

1 Answer 1

6

That takes a 4 character long substring of TEMPRPSW, starting from character 0. Meaning, it takes the first 4 characters of TEMPRPSW and puts them in RELVER.

set TEMPRPSW=abcdef set RELVER=%TEMPRPSW:~0,4% echo %RELVER% -> will print abcd 

%VAR:str=% removes str

set RELVER=123.456 set RELVER=%RELVER:.=% echo %RELVER% -> will print 123456 with no . 

here is a nice article: https://www.dostips.com/DtTipsStringManipulation.php

Sign up to request clarification or add additional context in comments.

4 Comments

What does this line set RELVER=%RELVER:.=% doing?
Great! It helps. :)
By the way, there's no need to go to a web site which may or may not be there at some point in the future. The web site may well be better but all the information you need is available to you with a simple set /?.
@paxdiablo +1 precisely. Noted for this. ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.