Community
    • Login

    How to batch remove all lines after the nth line?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 484 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.
    • melanievtM
      melanievt
      last edited by

      I have a bunch of text files each having a different number of lines. I want to keep only the first 100 lines in each file. How can I do that?
      Thanks in advance,
      Mel

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

        @melanievt

        Find: \A(?-s)(?:^.*\R){100}\K(?s).*
        Replace: nothing
        Search mode: Regular expression

        Suggest backing up all of your data before trying this.

        melanievtM 1 Reply Last reply Reply Quote 4
        • melanievtM
          melanievt @Alan Kilborn
          last edited by

          Works like a charm! Thank you very much @Alan-Kilborn🙏🏽

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

            @melanievt

            Learn more to be able to apply such techniques on your own in the future; start HERE.

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