Try this short piece of code:
@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%A in ('net view /domain:workgroup') do (
set comp=%%A
set comp=!comp:~2!
nbtstat -a !comp! >>MAC.txt
)
If you are wanting to have a specific output that is maybe only one or two lines per entry, it will require some additional work, so let us know if that is what you are wanting.