Reputation: 109
I have a Variable in my Batch %rev%
I need to check whether it contains a string "new" or it has a value of random numbers in it.
Any help Appreciated.
I was trying with the below code but it doesnt work.
if /I "%rev%"=="new" (
echo String has new
) else (
echo it doesnt has new
)
Upvotes: 4
Views: 10057
Reputation: 57252
you can try with :
if /I "%rev:new=%" neq "%rev%" (
echo String has new
) else (
echo it doesnt has new
)
or with (a little bit slower):
(echo(%rev%)|find /i "new" >nul && (
echo String has new
)||(
echo it doesnt has new
)
Upvotes: 3