Community
    • Login

    Delete All Lines After Bookmark then Combine Text Files

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 4 Posters 552 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ProfessorSethOP
      ProfessorSethO
      last edited by

      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!

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @ProfessorSethO
        last edited by

        @professorsetho

        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.

        1 Reply Last reply Reply Quote 0
        • guy038G
          guy038
          last edited by guy038

          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 specific folder

            • 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 specific folder

            • 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 in administrator mode )

          • Move to your directory containing these 385 documents

          • Type in the command copy *.txt Total.txt and valid with the Enter key

          => The Total.txt file is created and should contain a concatenation of all your 385 files. Of course, your individual files are not modified !

          Voilà :-))

          Best Regards,

          guy038

          Neil SchipperN 1 Reply Last reply Reply Quote 1
          • Neil SchipperN
            Neil Schipper @guy038
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • guy038G
              guy038
              last edited by guy038

              Hello, @neil-schipper,

              Thanks for pointing this to me ! So, I replaced the two plus signs with two star symbols, in my previous post

              BR

              guy038

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors