@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
For /f "tokens=1-5" %%A in (
'nmap -sP 192.168.1.*'
) Do If /I "%%B" equ "scan" (
set "IP=%%E"
) Else if /I "%%A" equ "MAC" (
Echo !IP!,%%C;
)
Exemplo de saída dos seus dados de teste:
192.168.1.1,2C:E4:12:EF:5B:72;
192.168.1.10,48:02:2A:06:A4:6F;
192.168.1.11,6E:2E:85:FF:FF:FF;
192.168.1.12,8C:18:D9:C8:A3:94;
192.168.1.13,B4:43:0D:AA:3F:6C;
192.168.1.16,F8:D1:11:18:74:89;
192.168.1.17,34:23:BA:4C:82:42;