Have files beginning with 15 lines of needed info, followed by 3280 extra lines of unneeded data.
Have tried multiple regex patterns to remove last 3280 lines in all files in directory.
Tried similar to:
^.*(?:\R.*){3279}\z
Fails every time when trying to replace with "" (empty) in directory of files.
Using Notepad++ Find in Files option.
How can I remove the last n number of lines from every file in the directory?
>Solution :
You can use
Find What: \A(.*(?:\R.*){14})(?s:.*)
Replace With: $1
Details:
\A– start of string (^would do, too, here)(.*(?:\R.*){14})– fifteen lines(?s:.*)– any text till end of the file (text).
The replacement is the backreference to Group 1 value.
Settings:
