Community
    • Login

    Batch delete a RANGE OF LINES in multiple files?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    batch removedeleting lines
    4 Posts 2 Posters 1.1k 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.
    • Mike MitchellM
      Mike Mitchell
      last edited by Mike Mitchell

      I am editing files in Poser Pro 11. They are text files that define the location and poses of rigged 3D objects. This is irrelevant info, but I provide it in case someone asks thinking that the language somehow matters to the task at hand.

      I have a range of text that I would like to delete from 50+ files.
      The text starts on line 10 and ends on line 57.

      In each of those files, I want to delete that range. Please note:

      • Although the opening is unique, the closing is not (there are LOTS of quadruple closing brackets in this file).
      • Rather than figure out some workaround about searching for a string of info (that occasionally changes: sometimes there is an extra space in there after a number or bracket), I would rather just delete the range of lines.

      Is this possible?
      If not, I am open to other suggestions. But please be mindful – the closing range is not unique.

      Sample of the text (copied from Notepad++)

      actor hip:1
      {
      channels
      {
      rotateY yrot
      {
      keys
      {
      k 0 -110
      }
      }
      rotateZ zrot
      {
      keys
      {
      k 0 -0
      }
      }
      rotateX xrot
      {
      keys
      {
      k 0 -5
      }
      }
      translateX xtran
      {
      keys
      {
      k 0 0
      }
      }
      translateY ytran
      {
      keys
      {
      k 0 -0.00400003
      }
      }
      translateZ ztran
      {
      keys
      {
      k 0 0
      }
      }
      }
      }

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

        @Mike-Mitchell

        Here’s a technique you might try (try it on ONE file, first, of course, and have backups of your data at all times!)
        .
        Find: (?s)(?<!\x0A)^((?:.*?\R){9})(?:.*?\R){48}
        Replace: \1
        Search mode: Regular expression

        What this does is match the first 57 lines, but it captures only the first 9 lines. Then it replaces the whole first-57-line blob with what was captured (i.e., the first 9 lines). Thus, effectively lines 10-57 get removed.

        You may have to tweak the numbers in the find expression a bit, I tried it out on something much smaller.

        1 Reply Last reply Reply Quote 3
        • Mike MitchellM
          Mike Mitchell
          last edited by

          You have effectively blown my mind!
          I’ll try it this evening and let you know if it works.
          Thank you very much!

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

            @Mike-Mitchell

            Well…let’s see how it goes on your data…

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