Extracting data from a .txt file

December 3, 2009 at 04:33:17
Specs: Windows XP, Varies
Recently, I made a batch file that ran ipconfig and copied that data into a text file for us to refer to. However, we now have all this useless data when all we really need is the IP address, MAC address, and computer name.

Is there anyway to take those subjects, and put them in another .txt file without having to manually do so?

Also, is there a way to do this from the start?

See More: Extracting data from a .txt file

Report •

December 3, 2009 at 05:33:55
Tested in w2k so you may need to tweak it a little.

@echo off & setLocal EnableDELAYedExpansion

for /f "tokens=* delims= " %%a in ('ipconfig /all') do (
echo %%a | find "Host Name"
echo %%a | find "Physical Address"
echo %%a | find "IP Address"
) >> ipconfig.log

Helping others achieve escape felicity


Report •

December 3, 2009 at 05:42:05
That works perfectly. My only questions are how to redirect the log file to go to our fileserver, and how to extract data from the txt files I already made.

(But, I can always redo the latter, I have nothing else to do atm.)

Report •

December 3, 2009 at 11:34:00
i think all you would need to do is change the following line:

for /f "tokens=* delims= " %%a in ('ipconfig /all') do (

for /f "tokens=* delims= " %%a in (oldlog.txt) do (

where "oldlog.txt" is whatever your existing old-format logfile is called.

for server redirection, if you have it mapped to a drive-letter,
("G:" for example) just put:
move ipconfig.log G:\whatever\ipconfig.log

as the very last line of the batch.

Report •

Related Solutions

Ask Question