• Login
Community
  • Login

copy 10 lines of code to all open documents

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 4 Posters 2.2k 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.
  • A
    Angelica Bartoloni
    last edited by Dec 21, 2017, 4:38 PM

    hello !
    I have to add a script in 80 html pages…
    can I paste all open documents?
    the script is about 10 lines
    thanks for answers

    1 Reply Last reply Reply Quote 0
    • J
      Jacob Currie
      last edited by Jan 4, 2018, 6:56 PM

      I would probably just write a script for this. maybe use batch or powershell to copy the text in you script, and append it to the end of your html.

      possibly ‘type’ (batch) or ‘out-file’ (powershell). Then just feed it a list of the file locations that need to get it and use a loop to add your script. Honestly, probably not worth the hassle, just paste em’ individually.

      simplified psuedo:
      for each line in ‘list of html paths’.txt
      append ‘script’.js to file at current line location

      1 Reply Last reply Reply Quote 0
      • V
        Vasile Caraus
        last edited by Jan 5, 2018, 8:25 PM

        you can use a regex like this: \A^.*(?:\R.*){10} in the best regex software named grepWIn. The best and simple solution. Search with a regex then copy all 10 lines from as much documents you want.

        but, my regex is not verry good. Maybe guy038 will find a better regex to select all first 10 lines :)

        1 Reply Last reply Reply Quote 0
        • V
          Vasile Caraus
          last edited by Jan 6, 2018, 5:48 AM

          could be \A(?:.*\n){10} but works just in sublime text, but not in notepad++

          1 Reply Last reply Reply Quote 0
          • G
            guy038
            last edited by Jan 7, 2018, 7:16 PM

            Hello, @angelica-bartoloni,

            As it’s my first post of 2018, allow me to wish you and every N++ user, a very productive year, with our beloved editor, a lot of opportunities and, of course, good health, throughout the year !


            Well, I supposed that all your HTML files are gathered in a specific folder, aren’t they ?

            The next question, Angelica, is : Where the script is supposed to be inserted, in these hmtl files ? I mean, could you give us the context ( a couple of lines before and after that insertion point ! )

            Finally, if not confidential, as it shouldn’t exceed 10 lines, could you, also post the script’s contents !

            With all that information, and the Built-in Replace / Replace in Files feature, it shouldn’t be very difficult to get the job done !

            See you later,

            Best Regards,

            guy038

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