Trying to check a string to see if it contains a substring in a Windows batch file.
This is what I still have:
echo %1 | find "message"
if %errorlevel% == 0 echo contains string
The command line output for this (the content of% 1 was "messages \ Message.js"):
messages \ Message.js
contains string
The problem that I encounter is that the only way to make it work with the exact string: echo %1 | find "js".
How can I do this without repeating the file path every time? When I delete echo, the operating system tries to open the file. I would like to save the path to the variable, but nothing I worked with always got an empty variable.
source
share