Question

I have a txt file :

[STATION NUMBER]
ST = 9992
[IP CONFIGURATIONS]
COMP1 = 128.1.7.9
COMP2 = 128.1.7.8
COMP3 = 128.1.7.7

I want to set varibles like this:

ST=9992
RFS=128.1.7.9
BOS=128.1.7.8
POS=128.1.7.7

i've tried to write something but I can't figure out how to proccess on line at a time:

for /f "skip=1 tokens=1,2,3" %%a in (ipsetting.txt) do echo %%c

if I use "SKIP=1" it gives me the second line and also third forth and etc..:

9992
128.1.7.9
128.1.7.8
128.1.7.7

please help

Was it helpful?

Solution

for /f "tokens=1,* delims== " %%i in ('find "=" ipsetting.txt') do set %%i=%%j

First trick: include only needed files (the lines, that have a =) (find "=")

second trick: eliminate spaces (with delims): use = and Space () as delimiters (multiple delimiters are treated as one, so in ST = 9992 token 1 is ST without trailing space and token 2 is 9992 without leading space)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top