Add new line of text at end/target line for multiple files?
VampireSeraphin last edited by
Hello. I would like to use the find and replace function across multiple text files to add a new line to the end of the file, or even better, to a target line (second line in this case).
This tutorial is very close to what I want to do: https://notepad-plus-plus.org/community/topic/11987/add-line-of-text-to-beginning-of-multiple-files/4 but I’m not sure how to modify it for my needs.
Does anyone know how I can do this?
Claudia Frank last edited by
give it a try with the following (regex and match newline needs to be checked)
Find what: ^(.*?\r\n)(.*)$ Replace: \1SomeText\r\n\2
^ Start from beginning of file and the ? restricts to find as less as possible chars until a \r\n (windows end of line marks) appears
which basically means the first line. Having enclosed in () means it get captured in variable \1 .
Next capture group gets the rest of the text until $ end.
In replace you need to add the text and the eols \r\n together with the matching groups.