Delete All Lines After Bookmark then Combine Text Files
-
Hi! I have a set of 385 text documents which all have a consistent format – headings are always the same, but content under them differs. The files are viewable on my Google drive: R2d documents
For each document, I want to delete the heading and everything after the heading “REPORTER’S NOTES”. I know that I can mark this text with bookmarks, but I cannot figure out how to automatically select and delete everything that follows after that. Help invited and welcomed!
Also, when this process is complete, I want to concatenate the 385 documents into a single document. Does notebook++ have a concatenate feature?
This is for an educational project. Many thanks in advance for helping me provide reference information to students!
-
I really don’t think many people want to click a link for your google drive.
The proper way to do it is to post a sample of your text here.
The best instructions for posting such a question are HERE.I want to concatenate the 385 documents into a single document. Does notebook++ have a concatenate feature?
Short and sweet answer: No.
-
Hello, @professorsetho, @alan-kilborn and All,
Not difficult to achieve !
I assume that :
-
All your
385
documents are in a specific folder -
Each of these files contains only one heading
REPORTER’S NOTES
-
You already backup these
385
documents within an other folder
Then, here is the road map :
-
Start Notepad++
-
Open the Find in files dialog (
Ctrl + Shift + F
)-
Find what:
(?-si)^.*REPORTER’S NOTES(?s).*
-
Replace with:
Leave EMPTY
-
Filters:
*.txt
-
Directory:
Your
specificfolder
-
Select the
Regular expression
search mode -
Click on the
Replace in Files
button -
Valid the
Are you sure?
dialog
-
=> For all your files, it will delete the line containing the string
REPORTER’S NOTES
and any text which follows-
IF, in addition, you want that you future single document contains a separation line, between each document, use, for instance, the following regex S/R :
-
Find what:
\z
-
Replace with:
\r\n================================================================================\r\n
-
Filters:
*.txt
-
Directory:
Your
specificfolder
-
Select the
Regular expression
search mode -
Click on the
Replace in Files
button -
Valid the
Are you sure?
dialog
-
-
Close the Find in files dialog (
Esc
) -
Now, open a
cmd
window ( no need to open it inadministrator
mode ) -
Move to your directory containing these
385
documents -
Type in the command
copy *.txt Total.txt
and valid with theEnter
key
=> The
Total.txt
file is created and should contain a concatenation of all your385
files. Of course, your individual files are not modified !Voilà :-))
Best Regards,
guy038
-
-
Hi @guy038,
Find what:
(?-si)^.+REPORTER’S NOTES(?s).+
The
^.+
requires at least one character at line start before ‘REPORTER’S NOTES’ but all the files I sampled have that text in the 1st column. -
Hello, @neil-schipper,
Thanks for pointing this to me ! So, I replaced the two
plus
signs with twostar
symbols, in my previous postBR
guy038