Wildcard in batch file

I was wondering how to check a group file in a batch file

SET /p project=Enter project (XYZ_2016_123)

      

I need to check if there is a variable project in XYZ_20 format ?? _ 123 where ?? two digits. Ignore the XYZ and 123 part of the entry. At the moment I have a lot of applications to check if there is a year. But I was wondering if it can be done using wildcards?

s=%project%
if not x%s:XYZ_2016_123=%==x%s% GOTO MAIN
if not x%s:XYZ_2017_123=%==x%s% GOTO MAIN
if not x%s:XYZ_2018_123=%==x%s% GOTO MAIN
:: etc.

      

+3


source to share


1 answer


try like this:

echo %s%|findstr /r "XYZ_20[0-9][0-9]_123" >nul 2>nul && (
  GOTO MAIN
)

      



FINDSTR

+4


source







All Articles