How to delete lines 2, 3, 4, 5 in multiple txt files at once?
-
How to delete lines 2 to 5 in multiple txt files?
I’ve tried pressing ctrl+shift+F and finding certain perameters, with regEx checked, but I cannot figure out what to search for to delete lines 2, 3, 4, 5.
Ideas?
-
@Chris-ball said in How to delete lines 2, 3, 4, 5 in multiple txt files at once?:
How to delete lines 2 to 5 in multiple txt files?
If you are replacing in files which aren’t opened in Notepad++ then this should work for you, it did in a small test for me.
Using the “Find in Files” option we have
Find What:(?-s)\A(.+\R)(.+\R){4}
Replace With:\1
You would need to set the filters and directory to correspond with the file types and location you are working on.
Just so you have understanding of what this regex is doing:
(?-s) means the DOT character does NOT include line feed/carriage returns
\A this means “start of file”. I tested my regex first as this \A can cause issues, in this case it did not appear to.
(.+\R) select as many characters as possible (the (?-s) prevents it from spreading past the line ending) and include the line ending (\R). This is capture group #1
(.+\R){4} same as last portion except the {4} means 4 more the same. This then selects lines 2-5
\1 means return the first capture group back to the file, so this is line 1Terry