I have searched the forum and see this question asked often but I can not seem to get it to work for me. I am trying to set a variable when a value equals Y. Here is what I think should work but mer2 is not being set.
setlocal ENABLEDELAYEDEXPANSION
for /F "tokens=*" %%A in (C:\SOMEFILE.txt) do (
set var=%%A
set mer1=!var:~0,1!
if "!mer1!"=="Y" (
set mer2=!1.5!
)
set "y=!mer1!,!mer2!"
echo !y!>>C:\SOMENEWFILE.csv
)
MY input file looks like this
Y
Y
N
N
Y
My expected output is this:
Y,1.5
Y,1.5
N,
N,
Y,1.5
What am I doing wrong?