file1 : iplist.txt
"10.10.1.52","Person U","Location a"
"10.10.1.53","Person Q","Location a"
"10.10.1.54","Person X","Location b"
"10.10.1.55","Person Z","Location c"
file2 : sh_arp.txt
inside,10.10.1.52,0023.70eb.5315,3
inside,10.10.1.53,0023.71eb.3312,4
inside,10.10.1.54,0024.91c2.32b0,5
inside,10.10.1.55,39e4.dec3.234d,9
The code I used is this
Code: Select all
@echo off & setlocal enabledelayedexpansion
for /f "tokens=1,2,3 delims=," %%a in (iplist.txt) do (
set ipa=%%a
set nam=%%b
set loc=%%c
for /f "useback tokens=*" %%a in ('!ipa!') do set ipa=%%~a
set ^"$CMD=find ",%%~a," sh_arp.txt^
"
for /f "tokens=1,2,3 delims=," %%a in ( '!$CMD!' ) do set mac=%%c
: set nmac=%mac:~0,2%-%mac:~2,2%-%mac:~5,2%-%mac:~7,2%-%mac:~10,2%-%mac:~12,2%
if not "!mac!" == "" echo !mac!,!nam!,!loc! > newlist.txt
)
goto:EOF
The remaining problem is that the mac address has the wrong format hence my inital attempt to turn the acbd.1234.5678 into ac-bd-12-34-56-78
Code: Select all
set nmac=%mac:~0,2%-%mac:~2,2%-%mac:~5,2%-%mac:~7,2%-%mac:~10,2%-%mac:~12,2%
But right now I cant touch these vars, I need to use the ! to get to them in the echo statement
How could I get to the variable in the %var% notation again?
Thanks