Add new line of text at end/target line for multiple files?
-
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?
-
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.
Cheers
Claudia
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login