Computing.Net > Forums > Programming > Extract First Line of Text

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Extract First Line of Text

Reply to Message Icon

Name: CWoodward
Date: February 7, 2006 at 15:10:33 Pacific
OS: Windows XP
CPU/Ram: Intel Celleron
Comment:

Hello! I would like to use a batch file to extract the first line of a text file and send it to a new text file.

Thanks,
Cale




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: February 7, 2006 at 22:04:57 Pacific
Reply:

Try this:

::== firstLIN.bat
@echo off
if %1'==' echo which file? && goto :eof

set DONE==N
for /f "tokens=*" %%L in (%1) do call :1 %%L
goto :eof

:1
if %DONE%==Y goto :eof
echo %*>outFILE
set DONE=Y
goto :eof

:eof
:: DONE

The :eof declaration is not necessary; it's built into NT. [Just my old habits.]



If at first you don't succeed, you're about average.

M2Go


0

Response Number 2
Name: CWoodward
Date: February 8, 2006 at 16:16:55 Pacific
Reply:

Perfect, thanks a million M2Go


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Extract First Line of Text

Delete first line of text www.computing.net/answers/programming/delete-first-line-of-text/13312.html

Delete First Line of Text www.computing.net/answers/programming/delete-first-line-of-text/13940.html

.bat delete first line of text file www.computing.net/answers/programming/bat-delete-first-line-of-text-file/13773.html