more /E +1 YourFilenameHere > YourFilenameHere.modified
Alternatively, this batch below will skip however many lines the user
wants in whatever file they want, exportd to whatever file they want.
Tested on Windows XP SP2.
New lines start with a line number, wrapped lines do not, merge wraped
lines onto previous line and remove line numbers before running script.
===Script: LN.cmd===
01. @echo off
02. cls
03. if "%1" NEQ "" if "%2" NEQ "" if "%3" NEQ "" GOTO :go
04. echo SYNTAX: ln ## FILENAME FILENAME2
05. echo --------------------------------
06. echo ## -- # of lines to skip
07. echo FILENAME -- File to Look Into
08. echo FILENAME2 -- File to Export Too
09. echo/
10. goto :eof
11.
12. :go
13. echo/
14. echo/
15. if NOT EXIST %2 (echo %2 -- Does not exist, try again! && goto
:eof)
16. echo Processing %2, skipping %1 lines and exporting to %3...
17. for /f "tokens=* Skip=%1" %%a in (%2) do echo %%a>>%3
===End: LN.cmd===
How it works:
Line 15 goes out and checks to see if the 'host' file exists, if not,
errors out and quits.
Line 17 is broken down as thus:
for /f "tokens=*
---Tells the script to include everything within the file
skip=%1
---Number of lines to skip at the start of the file
%%a in (%2)
---The Host file and export variable.
do echo %%a >> %3
--- echo's all the data after the # of skiped lines to %3, the output
file.
Hope that helps!
*Watch for wrapped lines!*
===Script: LN.cmd===
01. ::@echo off
02. cls
03. if "%1" NEQ "" if "%2" NEQ "" if "%3" NEQ "" GOTO :go
04. echo SYNTAX: ln ## FILENAME FILENAME2
05. echo --------------------------------
06. echo ## -- # of lines to skip
07. echo FILENAME -- File to Look Into
08. echo FILENAME2 -- File to Export Too
09. echo/
10. goto :eof
11.
12. :go
13. for /f "tokens=3 delims= " %%a in ('find /i /c " " %2') do set
count=%%a
14. if %1 GTR %count% (echo Sorry, the file doesn't have that many
lines. && got
o :eof)
15. echo/
16. echo/
17. if NOT EXIST %2 (echo %2 -- Does not exist, try again! && goto
:eof)
18. echo Processing %2, skipping %1 lines and exporting to %3...
19. for /f "tokens=* Skip=%1" %%a in (%2) do echo %%a>>%3
===End: LN.cmd===
And the more command couldn't also be adapted and more easily so?
more /E +n originalfilename > whateverotherfilenameyouwant
If you have to wrap it in a batch file,
@echo off & setlocal enabledelayedexpansion
if not "%1" == "" if not "%2" == "" if not "%3" == "" goto :BEGIN
echo Usage: %0 startline inputfilename outputfilename
goto :EOF
:BEGIN
set /a n=%1 - 1
more /E +%n% "%~2" > "%~3"
But even this seems like gross overkill for such a simple task. Yours
is baroque overkill. There a times a single built-in program does beat
dozens of lines of batch file code. Putting it differently, sometimes
it's a bad idea to reinvent the wheel.
#1. I proposed an alternative.
#2. I never said it was better.
#3. I never stated that the more command couldn't be adapated.
#4. This is an open forum, all ideas, no matter how much 'overkill'
they seem to someone else are acceptable here.
Thanks.
You implied the more command couldn't be adapted in how you phrased
your 'Alternatively' paragraph.
>#4. This is an open forum, all ideas, no matter how much 'overkill'
>they seem to someone else are acceptable here.
And one person's proposed alternatives are also open to the criticism
of others. You have the right to post useless code, but you shouldn't
fool yourself that others don't have the right to point out your
useless code for what it is.
And everyone has the right to chime in on character assessment even if
they've never posted a single line of batch code.
>>>Can anyone think of an easy way in a batch file to delete the first line
>>> in a 2000-line text file, and save the modified file to a new name?
>>more /E +1 YourFilenameHere > YourFilenameHere.modified
> Alternatively, this batch below will skip however many lines the user
> wants in whatever file they want, exportd to whatever file they want.
> 16. echo Processing %2, skipping %1 lines and exporting to %3...
> 17. for /f "tokens=* Skip=%1" %%a in (%2) do echo %%a>>%3
A flaw in this method, Phillip, is that blank lines are not retained.
In article <1148334071.3...@y43g2000cwc.googlegroups.com>,
hrl...@aol.com says...
Thanks foxi.
@echo off
for /f %%i in ('ipconfig/all ^| find /i "%computername%"') do set
var_1=%%i
for /f "tokens=2" %%i in ('ipconfig/all ^| find /i "%computername%"')
do set var_2=%%i
for /f "tokens=3" %%i in ('ipconfig/all') do set var_3=%%i & goto
:sub1
:sub1
for /f %%i in ('ipconfig/all') do set var_4=%%i
for /f "skip=15" %%i in ('ipconfig/all') do set var_6=%%i & goto
:sub2
:sub2
for /f "skip=1" %%i in ('ipconfig/all') do set var_7=%%i & goto :sub3
:sub3
set var1=%var_1:~0,1%
set var2=%var_2:~1,1%
set var3=%var_3:~7,1%
set var4=%var_4:~7,1%
set var5=%var_3:~12,1%
set var6=%var_6:~0,1%
set var7=%var_7:~6,1%
set var8=%var_4:~1,1%
set var9=%var_6:~3,1%
set var10=%var_2:~3,1%
set harlan=%var1%%var2%%var3%%var4%%var2%%var5% =
%var6%%var7%%var7%%var8%%var9%%var4%%var10% !
:loop
echo %harlan%
ping -n 2 localhost>nul
goto :loop
You need the first line of a file? If so, then it's FAQ time
23} How do I get the n'th, the first and the last line of a text file?
69} How do I get the first, or the last, 400 lines of a file?
163586 May 1 2006 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html
Well, you've certainly proven your own qualifications as an asshole.
Guess there can be more than one. Now if you could just manage the
occasional useful post . . .
Ovbiously your mind is chiming FAQman, FAQman, FAQman. :-)
All the best, Timo (aka Perfesser Pundit in news:rec.humor)
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Perfesser's nauseating puns: ftp://garbo.uwasa.fi/pc/ts/tspun23.zip
The method that work the best was "sed"
when I open in Notepad all the words were together.
when I open in Word it figured out the format.
All appeared correct without any errors. Batch parsed the
entire log in 2-3 seconds perfectly (365 pages.)
"foxidrive" <woo...@gotcha.invalid> wrote in message
news:1zx7piurzwt8.9...@40tude.net...