Code will not iterate through file
Posted: 12 Dec 2011 15:20
I have a script designed to read a text file and make parameters of the elements of each line, then act on them. However, it just returns info for the last line for as many times as there are lines in the input file. Here's the code:
And here's an example input file:
And the output:
I figure it must be the parameters in the for command, but I can't get it to work for the life of me... any suggestings very appreciated!
Regards, Al
Code: Select all
@Echo Off
setlocal EnableDelayedExpansion
Set _InputFile=master.txt
For /F "tokens=1-6 delims=|" %%A IN (%_InputFile%) DO (
Set _server=%%A
Set _database=%%B
Set _username=%%C
Set _pwd=%%D
Set _name=%%E
Set _type=%%F
echo Processing %_server%
if "%_type%"=="s" (
[do stuff...]
) else (
[do stuff...])
)
And here's an example input file:
Code: Select all
servera|dba|usera|xxx|DM|s
serverb|dbb|userb|yyy|PMT|m
And the output:
Code: Select all
Processing dbb
Processing dbb
I figure it must be the parameters in the for command, but I can't get it to work for the life of me... any suggestings very appreciated!
Regards, Al