|I feel this should be simple but can't find any answers elsewhere.|
I'm trying to search a text file and when the string "MAC address =" is found output the text to a new text file. My code so far is as follows:
echo Please enter input filename:
set /p filein=
echo please enter output filename:
set /p fileout=
echo Please wait, generating list
for /F %%I in (%filein%) DO (nbtstat -A %%I | find /i "MAC")>>%fileout% && (echo ip= %%I)>> %fileout%
but obviously this only outputs the entire line the string is found on. I'm guessing tokens are involved but I'm too newbie to get it :S
thanks in advance for any help.
Note: The entire mini project that I'm trying to complete does the following:
one batch generates a list of IP addresses eg
for /L %%I in (1,1,254) DO echo 192.168.0.%I >> %file%
Then another uses this file as input to resolve the Mac address using nbtstat.
I then hope to merge the two to a 3rd text file and have a format similar to
192.168.0.8;5C59484586B1;(null); ie IP;MAC address;hostname(optional)
Sorry if this seems overly complicated, I may have over explained myself!