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.
Delete 1st 4 lines & last 8 Lines in TXT File
Name: DealMaker Date: July 13, 2009 at 02:28:50 Pacific OS: Windows XP Subcategory: Batch
Comment:
Hello,
Can anyone help with a BAT file which will open a txt file and delete the first four lines and the last five lines. The text file has a header and footer which needs to be removed:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 NotDashEscaped: You need GnuPG to verify this message
I have this code which deletes the first four lines (see below) does anyone have something I can add to it to delete the last 8 lines?
Thanks in advance,
Brett
Code to delete the first 4 lines:
@echo off setLocal EnableDelayedExpansion
if exist *.new del *.new
for /f "tokens=* delims= " %%A in ('dir /b *.txt') do ( set NAME=%%~nA set fileNAME=%%A for /f "tokens=* skip=4 delims= " %%L in (!fileNAME!) do ( echo %%L >> !NAME!.new ) ) ::==
Summary: I have a txt file called elements.txt that contains content similar to this: ---------- C:\TEMP\1000604\SAMPLEALBUM\1000604\LAST\LAST.PCK PIC_FRAME_NAME = fr_3d - beveled 01 - large landscape --------...
Summary: I agree that some more info would have been helpful. But, I will make some assumptions. I wil assume that you want to change the first line in some file X.txt from something to "A B C". The following...
Summary: Hy! My problem is How can get open the first line in txt file. Example: File name :"list.txt" in side file.log file2.log file3.log etc.... Im can try to open de first file (f...