I've been banging my head for hours and realize I need some help
I'm generally a linux guy, so scripting in windows gets me all foggy with syntax.
Here's what I need to do.
I have a text file called approved.txt. Within it, it has the following
group1
group2
group3
I need to parse this file, and check every line against an if/then block to assign a new variable. I then need to feed those new values to a different command. I tried the following
set tfgroup=""
for /F "delims=" %%a in (%approvallist%) do (
if &&a == "group1"
(
set tfgroup=group1002
%newcommand% %tfgroup%
)
if %%a == "group2"
(
set tfgroup=group1003
%newcommand% %tfgroup%
)
)
however the results I was getting seemed to indicate that there's a syntax problem with my if statement. (using @echo on)
---------
The syntax of the command is incorrect.
C:\> IF %a == "group1"
C:\>
If I comment out the 2 IF statements and simply do a echo %%a I get the results of my text file, so I assume my for loop is ok.
What is frustrating, is that I've used IF statements in batch scripts before, and previously IF %variable% == somestring DO something.
I've never actually tried to set the %%a from a for loop to a new variable, I've used it as iterations to complete other tasks.
Does anyone know where I'm going wrong? The fact that the error is calling out my IF statement really makes me suspect it
IF %a == "group1"
I'm generally a linux guy, so scripting in windows gets me all foggy with syntax.
Here's what I need to do.
I have a text file called approved.txt. Within it, it has the following
group1
group2
group3
I need to parse this file, and check every line against an if/then block to assign a new variable. I then need to feed those new values to a different command. I tried the following
set tfgroup=""
for /F "delims=" %%a in (%approvallist%) do (
if &&a == "group1"
(
set tfgroup=group1002
%newcommand% %tfgroup%
)
if %%a == "group2"
(
set tfgroup=group1003
%newcommand% %tfgroup%
)
)
however the results I was getting seemed to indicate that there's a syntax problem with my if statement. (using @echo on)
---------
The syntax of the command is incorrect.
C:\> IF %a == "group1"
C:\>
If I comment out the 2 IF statements and simply do a echo %%a I get the results of my text file, so I assume my for loop is ok.
What is frustrating, is that I've used IF statements in batch scripts before, and previously IF %variable% == somestring DO something.
I've never actually tried to set the %%a from a for loop to a new variable, I've used it as iterations to complete other tasks.
Does anyone know where I'm going wrong? The fact that the error is calling out my IF statement really makes me suspect it
IF %a == "group1"