Community
    • Login

    copy 10 lines of code to all open documents

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 4 Posters 2.5k Views 3 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.
    • Angelica BartoloniA Offline
      Angelica Bartoloni
      last edited by

      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
      • Jacob CurrieJ Offline
        Jacob Currie
        last edited by

        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
        • Vasile CarausV Offline
          Vasile Caraus
          last edited by

          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
          • Vasile CarausV Offline
            Vasile Caraus
            last edited by

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

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

              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

              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