Community
    • Login

    Mass replace in multiple files - part is same everywhere, part is different in every file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    mass replace inmultiple files
    3 Posts 2 Posters 677 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.
    • Stanislav Elvenisko HoferekS
      Stanislav Elvenisko Hoferek
      last edited by

      Hello. Can anyone help me? I wish to mass replace strings, that have some “standard” characters, that are same in multiple files, and some specific characters, that are only in 1 file.

      So i wish to change:

      SOME_COMMON_CONTENT_BEGINNING:abcdef123:SOME_COMMON_CONTENT_end
      SOME_COMMON_CONTENT_BEGINNING:abcdef456:SOME_COMMON_CONTENT_end
      SOME_COMMON_CONTENT_BEGINNING:abcdef789:SOME_COMMON_CONTENT_end

      TO:

      SOME_COMMON_CONTENT_BEGINNING:anything:SOME_COMMON_CONTENT_end
      SOME_COMMON_CONTENT_BEGINNING:anything:SOME_COMMON_CONTENT_end
      SOME_COMMON_CONTENT_BEGINNING:anything:SOME_COMMON_CONTENT_end

      how can i do it? using current notepad ++. Many many thanks :)

      1 Reply Last reply Reply Quote 1
      • Stanislav Elvenisko HoferekS
        Stanislav Elvenisko Hoferek
        last edited by

        also, all the files are looong. so i dont want to do the change to the end of the file, just to the end of the line.

        so a file looks like:

        lorem ipsum1
        lorem ipsum2
        SOME_COMMON_CONTENT_BEGINNING:abcdef456:SOME_COMMON_CONTENT_end
        lorem ipsum3
        lorem ipsum4

        NOW I HAVE A SOLUTION:

        replace this: XXXXXXXXXX.*YYYYYYYYYY
        with whatever you want :) So one dot and one * is enough. Working in the middle of the files as well…

        1 Reply Last reply Reply Quote 2
        • Terry RT
          Terry R
          last edited by Terry R

          @Stanislav-Elvenisko-Hoferek
          I’m not sure what your second post was meant to say. Did you even try that?

          My suggestion is start with 1 file opened in NPP and test what I provide. If it works the same method can also work on a bunch of files using the other tab of the Replace function called “Find in Files”.
          So
          Find What:(SOME_COMMON_CONTENT_BEGINNING:)(.+?)(:SOME_COMMON_CONTENT_end)
          Replace With:\1anything\3
          This is using your terminology. Up to you to replace the strings SOME_COMMON_CONTENT_BEGINNING:
          anything and
          :SOME_COMMON_CONTENT_end
          with what your actual data is. Note I did bracket the text we will replace (.+?), this is not necessary, but it won’t change the result.

          Terry

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