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 900 Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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

          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
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors