|Create File containing IP addresses from file with Workstation List|
The following shows how each line of a text file can be processed:
@echo off SetLocal set ListWsnName=ComputerNames.txt set ListIpAddrWorking=out\IpAddressesWorking.txt set ListIpAddrAll=out\IpAddressesAll.txt @md out >nul 2>&1 @del "%ListIpAddrWorking%" >nul 2>&1 @del "%ListIpAddrAll%" >nul 2>&1 @echo. for /F "delims=" %%l in (%ListWsnName%) do ( for /f "tokens=3 delims=: " %%p in ('ping.exe -n 1 %%l ^| find " TTL="') do echo %%p >> "%ListIpAddrWorking%" for /f "tokens=2 delims=" %%p in ('ping.exe -n 1 %%l ^| find " ["') do echo %%p >> "%ListIpAddrAll%" ) @echo.
In the above I'm creating two lists, one that only contains IP addresses for workstations that can currently be pinged and another containing all that successfully resolve to an IP address (they may be turned off or unavailable).