I have a text file called string.txt
----------------------
T501-08680-0101
T501-08815-0100
T501-08665-0102
T501-01110-0102
---------------------------
I have the following code to check if the string exist in this text file then set old_prof=xxx
Code: Select all
@echo off
::Mockup
findstr /c:"T501-08680" string.txt
if not errorlevel 1 (
set old_prof=Mockup
echo %old_prof%
) else (
goto QA_Infra
)
:QA_Infra
findstr /c:"T501-08815" string.txt
if not errorlevel 1 (
set old_prof=QA_Infra
echo %old_prof%
) else (
goto NAR_Infra
)
:NAR_Infra
findstr /c:"T501-08665" string.txt
if not errorlevel 1 (
set old_prof=NAR_Infra
echo %old_prof%
) else (
goto MY_Prof
)
:MY_Prof
findstr /c:"T501-01110" string.txt
if not errorlevel 1 (
set old_prof=MY_Prof
echo %old_prof%
) else (
goto end
)
:end
1) I modify the string.txt as
T501-08680-0101
T501-18815-0100
T501-18665-0102
T501-11110-0102
it works fine and old_prof=Mockup
2) I modify the string.txt as
T501-18680-0101
T501-08815-0100
T501-18665-0102
T501-11110-0102
it works fine but old_prof=Mockup instead of QA_Infra
Why the set value always set the previous one ??
Thanks