Please help.
I have a statement as :
for /f "tokens=3,* delims=:. " %%a in ('"ipconfig|find "IP Address""') do set ip=%%b
This will gives me all the IP Address of the system. I would like to eliminate ONLY the first local Active IPAddress, and ignore the rest. Appreciated any help.
Parse For /F
Moderator: DosItHelp
tom4tp,
you could try the (new) :getIPConfig function. It returns an array of all ipconfig output, from there you can access what you need.
DosItHelp?
you could try the (new) :getIPConfig function. It returns an array of all ipconfig output, from there you can access what you need.
@echo off
call:getIPConfig arr
echo.%arr[1].IPAddress%
echo.%arr[2].IPAddress%
echo.%arr[3].IPAddress%
goto:eof
rem copy :getIPConfig function from http://www.dostips.com/DtCodeCmdLib.php#Function.getIPConfig
DosItHelp?
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
You can use a goto statement to effectively break out of (most) for loops:
So this code will only execute the set command once, and then it'll exit the for loop and continue on.
Code: Select all
for /f "tokens=3,* delims=:. " %%a in ('"ipconfig|find "IP Address""') do set ip=%%b && goto :continue
:continue
echo other stuff
So this code will only execute the set command once, and then it'll exit the for loop and continue on.