I have written this piece of code for separating names which I need to remove or retain.
- input.txt --> Input file containing the names
- retain.txt --> Predefiled list of names which should not go in output.txt
- output.txt --> txt file the code is creating after checking names of input.txt against retain.txt
It should set value of variable Text to R if name in input.txt do not match with the name in retain.txt and it should be set to A if they match. But when I execute it, I am always getting return value of function as R and thus all the groups go to output.txt which is wrong
@echo off
cls
::Picking group names from file
for /f "Delims=," %%a in (input.txt) do (
::Calling Inner loop to validate against retaining groups
CALL :InnerLoop Text
ECHO ReturnVal from Function: %Text%
if %Text%==R (
echo %%a >> output.txt
)
ECHO END
)
exit /B 0
:InnerLoop
for /f "Delims=," %%g in (retain.txt) do (
echo This combo is %%a and %%g
if not %%a==%%g (
set TEXT1=R
Echo Remove
) else (
set TEXT1=A
Echo Retain
echo TEXT1 is is %TEXT1%
set %~1=%TEXT1%
exit /B 0
)
)
echo TEXT1 is %TEXT1%
set %~1=%TEXT1%
Ironman is present in input.txt as well as retain.txt, so ideally it should not get written in output.txt
Aucun commentaire:
Enregistrer un commentaire