Need to pull line number from many files

May 6, 2011 at 09:32:27
Specs: Windows Vista
Hello! This is the same person from the post at http://www.computing.net/answers/pr... . I'm sorry to make a new discussion but my manager is breathing down my neck to get this solved and there's been no reply from the person who gave me their first block of code 6 days ago.

Mechanix2Go gave me this code to save the 38th line from a file:

:: ==========================================
::
:: alexg.bat Fri 29-04-2011 14:09:54.56
@echo off > newfile & setLocal enableDELAYedeXpansioN

for /f "skip=37 tokens=* delims= " %%a in (datafile) do (
> newfile echo.%%a
goto :eof
)


When I ran it, I discovered that it couldn't find a file called datafile, so I changed that variable to the name of one of the documents. That worked fine, pulled the line I wanted and put it in a file called "newfile".

:: ==========================================
::
:: alexg.bat Fri 29-04-2011 14:09:54.56
@echo off > newfile & setLocal enableDELAYedeXpansioN

for /f "skip=37 tokens=* delims= " %%a in (md50000001135.txt) do (
> newfile echo.%%a
goto :eof
)

This works OK, but what I really need is a batch file that will do EVERY file in the directory the same way, appending line 38 from each file as a new line in the output file. Any way to accomplish this? I'm so sorry to be pushy, but an answer today would be a Godsend.


See More: Need to pull line number from many files

Report •


#1
May 6, 2011 at 12:09:24
maybe use something like

FOR %%i IN (directory\*.*) DO echo %%i >> list.txt

for /f "tokens=* delims= " %%b in (list.txt) do (

for /f "skip=37 tokens=* delims= " %%a in (%%b) do (
>> list2.txt echo.%%a
goto :eof

maybe

mike


Report •

#2
May 6, 2011 at 13:46:59
Already done in the other thread.


=====================================
Life is too important to be taken seriously.

M2


Report •

#3
May 6, 2011 at 14:18:28
humble appologies, just trying to stop gap. thanks for the information

mike


Report •

Related Solutions


Ask Question