I have a textfile (filename.txt
) which contains
ProductABC_Test.txt
ProductDEF_Test.txt
ProductHIG_Test.txt
ProductIJK_Test.txt
I will be getting a variable passed (ex: product=ABC which will be substring of ProductABC_Test.txt). So I need to fetch the correct test name (ProductABC_Test.txt) from the filename.txt.
I have tried the following code -
SETLOCAL ENABLEEXTENSIONS
@echo off
set product=ABC
SETLOCAL EnableDelayedExpansion
for /F "tokens=*" %%A in (filename.txt) do
(
set str=%%A
if NOT %str% == !%str:product=%
(
set test_suite=%%A
)
)
ENDLOCAL
echo %test_suite%
But I am not getting the right result.