Check if variable contains text in BATCH
1 answer
Simple demo using conditional statements.
Look at this post (dbenham's answer) for a similar question How to conditionally take action if FINDSTR fails to find a string
C:\>set variable=5.13_01-01-2014
C:\>(echo %variable% | findstr /i /c:"update" >nul) && (echo Variable contains the string "update") || (echo Variable does not have the string "update")
Variable does not have the string "update"
C:\>set variable=5.13-update_01-01-2014
C:\>(echo %variable% | findstr /i /c:"update" >nul) && (echo Variable contains the string "update") || (echo Variable does not have the string "update")
Variable contains the string "update"
Cheers, G
+3
source to share