Question

I want to do 2 things if a statement equals a value, I am looking to rename then goto.

Any recommendations MUCH appreciated!

:BRAND
echo.
echo What brand are you staging?
echo.
echo          T = BRAND1
echo.
echo          M = BRAND2
echo.
echo          P = BRAND3
echo.
SET /P BRAND=T/M/P? 

IF /I '%BRAND%'=='T' REN C:\U.bmp V.bmp /y **THEN GOTO OK**
IF /I '%BRAND%'=='M' REN C:\W.bmp X.bmp /y  **THEN GOTO OK**
IF /I '%BRAND%'=='P' REN C:\Y.bmp Z.bmp /y  **THEN GOTO OK**

:OK
Was it helpful?

Solution

For your purposes, you really don't need the GOTO. But, if you need to do more than two things and/or keep things more readable, you can do this too:

IF /I '%BRAND%'=='T' (
  REN C:\U.bmp V.bmp /y
  GOTO OK
)
IF /I '%BRAND%'=='M' (
  REN C:\W.bmp X.bmp /y
  GOTO OK
)
IF /I '%BRAND%'=='P' (
  REN C:\Y.bmp Z.bmp /y
  GOTO OK
)

OTHER TIPS

IF /I '%BRAND%'=='T' ( REN C:\U.bmp V.bmp /y  & GOTO OK )
IF /I '%BRAND%'=='M' ( REN C:\W.bmp X.bmp /y  & GOTO OK )
IF /I '%BRAND%'=='P' ( REN C:\Y.bmp Z.bmp /y  & GOTO OK )
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top