Community
    • Login

    add new text in multiple files

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 2 Posters 3.9k 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.
    • guy038G
      guy038
      last edited by guy038

      Hello, @rajesh-patil ,

      Some precisions :

      • Does the new line (include "car_crew.inc") need to be inserted once or several times in each file ?

      • Is this line be inserted always at the same location ? ( I mean, for instance, always between the present lines 7 and 8 ! )

      • Will the lines (include "/properties/car.ext") and (include "/properties/shadow/tank.inc" scale(1.0)) always surround this new line ?

      See you later,

      Best Regards,

      guy038

      1 Reply Last reply Reply Quote 0
      • rajesh patilR
        rajesh patil
        last edited by

        •Does the new line (include “car_crew.inc”) need to be inserted once or several times in each file ?
        yes
        •Is this line be inserted always at the same location ? ( I mean, for instance, always between the present lines 7 and 8 ! )
        yes
        •Will the lines (include “/properties/car.ext”) and (include “/properties/shadow/tank.inc” scale(1.0)) always surround this new line ?
        yes

        all files are same…just want to insert (include “car_crew.inc”) in every file…there are too many files it will take me forever

        rajesh patilR 1 Reply Last reply Reply Quote 0
        • rajesh patilR
          rajesh patil @rajesh patil
          last edited by

          not exactly same top lines same bottom property are change…………….

          I cant edit my post…waiting time 2100…what is this ?

          1 Reply Last reply Reply Quote 0
          • guy038G
            guy038
            last edited by

            Hi, @rajesh-patil,

            Regarding the limited time of editing, it’s due to some spam attacks we had in the past, on this site. I agree with you and many others users that this delay should be highly increased for a nicer work. By now, only moderators of this site may re-open and change their own posts, without any limit !


            Regarding your problem, I didn’t clearly understand and I’m rather confused ! We must find some parameter(s) which identify, without ambiguity, the location where this line have to be inserted. For example :

            • Is it always after line 7, or any other, of each file ?

            • Or, as you said, must this line be inserted between two lines, which are always the same, whatever the file to scan ?

            • Or ?

            Cheers,

            guy038

            1 Reply Last reply Reply Quote 0
            • rajesh patilR
              rajesh patil
              last edited by

              (include “/properties/car.ext”)
              (include “/properties/shadow/tank.inc” scale(1.0))
              (include “/properties/selection/vehicle.inc” scale(1.1))
              {collider “truck”}

              this top line are same in every file

              (include “/properties/car.ext”)

              (include “car_crew.inc”) <-----can inserted here

              (include “/properties/shadow/tank.inc” scale(1.0))
              <------------ or inserted here
              (include “/properties/selection/vehicle.inc” scale(1.1))
              <------------- or inserted here
              {collider “truck”}
              <------------- or inserted here

              all I want insert this single line (include “car_crew.inc”) in all file at once

              1 Reply Last reply Reply Quote 0
              • guy038G
                guy038
                last edited by

                Hi, @rajesh-patil and All,

                Ok ! So, in other words, if you don’t mind about the location, among the four possible ones, that you proposed, we could simply tell that you need to insert the line (include "car_crew.inc"), after the line (include "/properties/car.ext") which always begins every file, which are to be scanned.

                If so :

                • First, I strongly advice you to backup your original files, before any operation !

                • Then, open the Find in Files dialog ( Ctrl + Shift + F )

                • Type the regex (?-is)^(\(include "/properties/car.ext"\)\R)(?s)(.+), in the Find what: zone

                • Type the regex \1\(include "car_crew.inc"\)\r\n\2, in the Replace with: zone

                • Fill the two other fields Filters and Directory:, as you like

                • Select the Regular expression search mode

                • Click on the Replace in files button and confirm the changes

                Et voilà !

                Cheers,

                guy038

                1 Reply Last reply Reply Quote 1
                • rajesh patilR
                  rajesh patil
                  last edited by

                  [link text]https://www.dropbox.com/s/9nttlapfrk7jrmx/notpad%2B%2B.jpg?dl=0(link url)

                  0 occurrences where replaced…plz check pic

                  1 Reply Last reply Reply Quote 0
                  • rajesh patilR
                    rajesh patil
                    last edited by

                    hi,
                    thanks for helping me…its works…but its works with only with first line…in my case

                    {game_entity
                    (include “/properties/car.ext”)
                    (include “/properties/shadow/tank.inc” scale(0.9))
                    (include “/properties/selection/vehicle.inc” scale(1.1))
                    {mass 1380}


                    (?-is)^((include “/properties/car.ext”)\R)(?s)(.+),
                    \1(include “car_crew.inc”)\r\n\2,

                    not works


                    (?-is)^({game_entity\R)(?s)(.+)
                    \1(include “car_crew.inc”)\r\n\2,

                    works


                    is it possible insert text between any line ?

                    1 Reply Last reply Reply Quote 0
                    • guy038G
                      guy038
                      last edited by guy038

                      Hi, @rajesh-patil and All,

                      OK, I understand ! I wrongly supposed that your text began the line, physically. But, of course, most of the time, your text is indented !

                      In that case change, both, the search AND the replacement part with the regexes below :

                      SEARCH : (?-is)^((\h+)\(include "/properties/car.ext"\)\R)(?s)(.+)

                      REPLACE : \1\2\(include "car_crew.inc"\)\r\n\3

                      Everything should be OK :-))


                      Remark :

                      IF your text contains several lines (include "/properties/car.ext"), in files, be aware that the regex S/R, above, adds the line (include "car_crew.inc"), only after the FIRST occurrence of (include "/properties/car.ext") !

                      If all is OK, I could, next time, give you some explanations on these regexes !


                      To get further information, you should have a look about the FAQ Desk post, below :

                      https://notepad-plus-plus.org/community/topic/15765/faq-desk-where-to-find-regex-documentation/1

                      See you later

                      Best Regards

                      guy038

                      1 Reply Last reply Reply Quote 1
                      • rajesh patilR
                        rajesh patil
                        last edited by

                        it works ….thank you so much…

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