Community
    • Login

    Possible to replace multiple text instances based on certain parent text?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 2 Posters 775 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.
    • Shannon GloverS
      Shannon Glover
      last edited by

      Hey everyone. First off, I’ve tried searching for this extensively with no luck…with the main problem being i’m really not sure of the verbiage I should be searching for. However, I expect this can be accomplished in some way…i’m just not sure how.

      Problem: I have a an entire directory with hundreds of files that need modified. The files are similar to an xml-type format. Essentially what I need to accomplish is to search for a specific number (31553) and replace it with 31554. Easy enough right. I can use the “Find in Files” feature to accomplish this. The issue I am running into is that every instance of 31553 I need to replace, below that in the respective xml attributes I also need to change a 0 to 1 for every instance I replace this in. See below:
      3a9beecf-f3d7-4f09-aa1d-54f6a9a2edf6-image.png

      Is there a way to accomplish this for an entire file directory? It’s not really feasible for me to mass replace all 31553 with 31554, then go back and update the 0’s to 1…since there will already be existing 31554 entries prior to these changes. There are hundreds of files that require this change, and tens of entries per file. Thanks for any advice here.

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

        @shannon-glover

        So this is going to depend upon surrounding data, which can’t be experimented with without a lot of retyping, because you posted a screenshot rather than some textual data.

        Try following instructions HERE for possibly better results.

        1 Reply Last reply Reply Quote 0
        • Shannon GloverS
          Shannon Glover
          last edited by

          Thanks for the advice. So…the original data entries will look similar to this:


          <Icon>
          <StatusItem item_color_off=“#00ff00” item_color_on=“#ff0000”>
          <RealTimeIcon>
          <UserDiagramIcon>
          <IonIcon resource_id=“51”>
          <Caption display_method=“none” caption_position=“8”></Caption>
          <Location left=“248” top=“500” bottom=“512” right=“262”></Location>
          <Handle>31553</Handle>
          <UniqueId>ea6d5d36-0456-43ad-8616-12cb2caa59db</UniqueId>
          </IonIcon>
          <Node use_parent_link=“0”>USS1A.MDS1A1WL</Node>
          </UserDiagramIcon>
          <Link type=“1”>
          <DDELink>
          <Service></Service>
          <Topic></Topic>
          </DDELink>
          </Link>
          <DblclickMethod action=“NOTHING”></DblclickMethod>
          <DrawBoxInfo border_width=“1”></DrawBoxInfo>
          <DisplayType>1</DisplayType>
          <CustomImage custom_image_is_multislot=“0” xlink:type=“simple” xlink:href=“x-pml:/diagrams/images/status_graphics/Brkr_V_Withdrawn_Blue.bmp” xmlns:xlink=“http://www.w3.org/1999/xlink”></CustomImage>
          <Label display_method=“custom” position=“RIGHT”></Label>
          </RealTimeIcon>
          <IonClass>21</IonClass>
          <Invert>0</Invert>
          </StatusItem>
          </Icon>


          In the end, the <Handle> will need to change to 31554, and the <Invert> will need to change to 1. See below:


          <Icon>
          <StatusItem item_color_off=“#00ff00” item_color_on=“#ff0000”>
          <RealTimeIcon>
          <UserDiagramIcon>
          <IonIcon resource_id=“51”>
          <Caption display_method=“none” caption_position=“8”></Caption>
          <Location left=“248” top=“500” bottom=“512” right=“262”></Location>
          <Handle>31554</Handle>
          <UniqueId>ea6d5d36-0456-43ad-8616-12cb2caa59db</UniqueId>
          </IonIcon>
          <Node use_parent_link=“0”>USS1A.MDS1A1WL</Node>
          </UserDiagramIcon>
          <Link type=“1”>
          <DDELink>
          <Service></Service>
          <Topic></Topic>
          </DDELink>
          </Link>
          <DblclickMethod action=“NOTHING”></DblclickMethod>
          <DrawBoxInfo border_width=“1”></DrawBoxInfo>
          <DisplayType>1</DisplayType>
          <CustomImage custom_image_is_multislot=“0” xlink:type=“simple” xlink:href=“x-pml:/diagrams/images/status_graphics/Brkr_V_Withdrawn_Blue.bmp” xmlns:xlink=“http://www.w3.org/1999/xlink”></CustomImage>
          <Label display_method=“custom” position=“RIGHT”></Label>
          </RealTimeIcon>
          <IonClass>21</IonClass>
          <Invert>1</Invert>
          </StatusItem>


          These 2 changes will need to be implemented for hundreds of repeating entries per file.

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

            @shannon-glover

            So maybe what you didn’t explicitly say is that the 2 areas of change are a “Handle” with a certain value and an “Invert” value of zero…both within the same “StatusItem” and “/StatusItem” hierarchy?

            Shannon GloverS 1 Reply Last reply Reply Quote 0
            • Shannon GloverS
              Shannon Glover @Alan Kilborn
              last edited by

              @alan-kilborn That is correct. This hierarchy <Icon> will repeat back to back throughout the document, each containing unique handles. I am only modifying the instances where the handle currently equals 31553.

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

                @shannon-glover

                So there’s an established technique for that.
                You seem to be pretty detail oriented, so give it a whirl and see if you can make it work.
                If not, post back again.
                Here’s the posting with the technique: https://community.notepad-plus-plus.org/post/62799

                Shannon GloverS 1 Reply Last reply Reply Quote 1
                • Shannon GloverS
                  Shannon Glover @Alan Kilborn
                  last edited by

                  @alan-kilborn Thank you. This is what I was anticipating after searching around a bit. I’ll take some time to familiarize myself with this and see if I can get it to work.

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