Solved I need to extract several lines from several .txt files

June 20, 2012 at 13:59:15
Specs: Windows 7
Okay, so I have a pile of .txt files, all of which I need to extract lines of data from. Eventually this data needs to go into an excel spreadsheet. I have no clue what tools to use to do this, or if a script would work.

There are multiple instances of the data within each .txt file, however I only need one copy of the data.

If there's any way to quickly do this, I would really appreciate any help.

I'm wanting to extract the data which specifically follows these three phrases:

Base ethernet MAC Address:
Top Assembly Serial Number :

See More: I need to extract several lines from several .txt files

Report •

June 20, 2012 at 19:28:26
✔ Best Answer
A batchscript should work, but I would need more specific description of your text files, specfically where the data is located in relation to your "key" phrases, and
an idea of the format of the data (since certain characters play havoc with batch scripts if not allowed for, such as > or & or | etc.) Also, the output format you want.
Obviously comma-separated, but how formatted, all in one file or multiple files, etc.
ap(config)#hostname data here?
Base ethernet MAC Address: data here?
Top Assembly Serial Number : sample data format?
here's a rough idea:
for /f %%a in ('dir /b *.txt') do (
for /f %%b in ('find "ap(config)#hostname"') do set x=%%b & goto :2
for /f %%b in ('find "Base ethernet Mac Address:"') do set y=%%b & goto :3
for /f %%b in ('find "Top Assembly Serial Number:"') do set z=%%b & goto :4
>>testfil echo %x%,%y%,%z%

There're probly easier ways to do this, but this gives an idea for one approach. The more specific you are with your output requirements and data format and availability, the better people can help.

Report •
Related Solutions

Ask Question