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
385documents are in a specific folder -
Each of these files contains only one heading
REPORTER’S NOTES -
You already backup these
385documents 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:
Yourspecificfolder -
Select the
Regular expressionsearch mode -
Click on the
Replace in Filesbutton -
Valid the
Are you sure?dialog
-
=> For all your files, it will delete the line containing the string
REPORTER’S NOTESand 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:
Yourspecificfolder -
Select the
Regular expressionsearch mode -
Click on the
Replace in Filesbutton -
Valid the
Are you sure?dialog
-
-
Close the Find in files dialog (
Esc) -
Now, open a
cmdwindow ( no need to open it inadministratormode ) -
Move to your directory containing these
385documents -
Type in the command
copy *.txt Total.txtand valid with theEnterkey
=> The
Total.txtfile is created and should contain a concatenation of all your385files. 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
plussigns with twostarsymbols, in my previous postBR
guy038
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