Community
    • Login

    combine plugin

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    17 Posts 6 Posters 17.5k 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.
    • dinkumoilD
      dinkumoil @0Raniere0
      last edited by dinkumoil

      @0Raniere0

      Also this task can be resolved with a small batch script if the following prerequisites are fullfilled:

      • None of the two files File1.txt and File2.txt contain empty lines that are not intentional. That means in your example data all empty lines have to be removed.
      • The two files File1.txt and File2.txt have equal number of lines or at least File1.txt is the one with more lines (in this case the output file will contain empty lines for every missing line in File2.txt).

      Store the following code as Merge.cmd and change lines 3 to 5 according to your needs. After double-clicking the script file it produces an output file that contains the content of both input files, mixed line by line.

      @echo off & setlocal enabledelayedexpansion
      
      set "InFile1=.\File1.txt"
      set "InFile2=.\File2.txt"
      set "OutFile=.\Merged.txt"
      
      (for /f "tokens=1* delims=:" %%a in ('findstr /n "^" "%InFile1%"') do (
         set "line="
         set /p "line="
         echo.%%b
         echo.!line!
      )) <"%InFile2%" >"%OutFile%"
      
      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @dinkumoil
        last edited by

        @dinkumoil said in combine plugin:

        with a small batch script

        I don’t downvote but really only Notepad++ related solutions should be discussed here.

        dinkumoilD 1 Reply Last reply Reply Quote 0
        • dinkumoilD
          dinkumoil @Alan Kilborn
          last edited by dinkumoil

          @Alan-Kilborn said in combine plugin:

          really only Notepad++ related solutions should be discussed here.

          Only telling people “don’t do it with Notepad++ because it’s the wrong tool” is not satisfying for them. If I know a small and simple solution I will keep posting it even if it is not Notepad++ related, simply because I want to help people.

          Alan KilbornA 1 Reply Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @dinkumoil
            last edited by Alan Kilborn

            @dinkumoil

            Users can Google for non-Notepad++ solutions; I can find a lot of solutions for poster’s need when I do it…and they don’t need to waste the Notepad++ bandwidth here.

            dinkumoilD 1 Reply Last reply Reply Quote 0
            • dinkumoilD
              dinkumoil @Alan Kilborn
              last edited by

              @Alan-Kilborn

              Ask yourself who is waisting bandwidth here in this thread …

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

                @dinkumoil said:

                Ask yourself who is waisting bandwidth

                You are, talking about non-Notepad++ related stuff.
                I am trying to keep the talk on a Notepad++ track.
                BTW check your spelling: Unless you’re talking about your mid-section, I don’t know what “waisting” is.

                because I want to help people

                Obviously with my amount of reputation points, I like helping people too, but only with Notepad++ related solutions to problems.


                It’s okay, I realize that you’re just sore at yourself because you realize you shouldn’t have been talking batch here. All is forgiven.

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

                  Hello, @0raniere0, @dinkumoil, @alan-kilborn and All,

                  Here is a real native N++ solution :

                  • Copy the File 1 contents :
                  1<source>Attempt to open %s failed!</source>
                  2
                  3<source>Cannot find a demuxer for %s</source>
                  4
                  5<source>width</source>
                  6
                  
                  • Copy the File2 contents, right after :
                  1
                  2<target>Tentativa de abrir %s falhou!</target>
                  3
                  4<target>Não foi possível encontrar um demuxer para %s</target>
                  5
                  6<target>largura</target>
                  

                  So we start with this INPUT text :

                  1<source>Attempt to open %s failed!</source>
                  2
                  3<source>Cannot find a demuxer for %s</source>
                  4
                  5<source>width</source>
                  6
                  1
                  2<target>Tentativa de abrir %s falhou!</target>
                  3
                  4<target>Não foi possível encontrar um demuxer para %s</target>
                  5
                  6<target>largura</target>
                  
                  • Do a rectangular selection of 12 × 1 characters '( the numbers ) at the very beginning of lines and hit the Delete key

                  => we get the TEMPORARY text, below :

                  <source>Attempt to open %s failed!</source>
                  
                  <source>Cannot find a demuxer for %s</source>
                  
                  <source>width</source>
                  
                  
                  <target>Tentativa de abrir %s falhou!</target>
                  
                  <target>Não foi possível encontrar um demuxer para %s</target>
                  
                  <target>largura</target>
                  
                  • Move at the very beginning of the line <target>Tentativa de abrir %s falhou!</target>

                  • Do a rectangular selection of 5 × 62 characters in order to grasp the complete lines

                  • Hit the Ctrl + X shortcut to delete the current rectangular selection

                  • Move to the empty line located between the two first lines <source>Attempt to open %s failed!</source> and <source>Cannot find a demuxer for %s</source>

                  • Hit the Ctrl + V shortcut to recopy your rectangular selection

                  => You should get your expected OUTPUT text :

                  <source>Attempt to open %s failed!</source>
                  <target>Tentativa de abrir %s falhou!</target>
                  <source>Cannot find a demuxer for %s</source>
                  <target>Não foi possível encontrar um demuxer para %s</target>
                  <source>width</source>
                  <target>largura</target>
                  

                  Best Regards,

                  guy038

                  P.S. :

                  Normally, the action of deleting the line numbers should not be necessary !

                  0Raniere00 1 Reply Last reply Reply Quote 3
                  • 0Raniere00
                    0Raniere0 @guy038
                    last edited by

                    @guy038 said in combine plugin:

                    Do a rectangular selection

                    Very interesting. This procedure actually gives the result I need. However, I need to join very large files with more than 6000 lines. How can I make this rectangular selection in files with so many lines?

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

                      Hi, @0raniere0, @dinkumoil, @alan-kilborn and All,

                      In case of huge files, @0raniere0, you can use the Begin/End Select feature of N++. As an example, I will use two files :


                      The File_1 file, which contains 6,000 lines :

                      This is the line N° 1 - This is the line N° 1 - This is the line N° 1
                      
                      This is the line N° 3 - This is the line N° 3 - This is the line N° 3
                      
                      This is the line N° 5 - This is the line N° 5 - This is the line N° 5
                      
                      This is the line N° 1 - This is the line N° 1 - This is the line N° 1
                      
                      This is the line N° 3 - This is the line N° 3 - This is the line N° 3
                      
                      This is the line N° 5 - This is the line N° 5 - This is the line N° 5
                      
                      This is the line N° 1 - This is the line N° 1 - This is the line N° 1
                      
                      This is the line N° 3 - This is the line N° 3 - This is the line N° 3
                      
                      This is the line N° 5 - This is the line N° 5 - This is the line N° 5
                      
                      ...
                      
                      ...
                      
                      This is the line N° 3 - This is the line N° 3 - This is the line N° 3
                      
                      This is the line N° 5 - This is the line N° 5 - This is the line N° 5
                      
                      

                      AND the File_2 file, which also contains 6,000 lines :

                      
                      This is the line N° 2 - This is the line N° 2 - This is the line N° 2
                      
                      This is the line N° 4 - This is the line N° 4 - This is the line N° 4
                      
                      This is the line N° 6 - This is the line N° 6 - This is the line N° 6
                      
                      This is the line N° 2 - This is the line N° 2 - This is the line N° 2
                      
                      This is the line N° 4 - This is the line N° 4 - This is the line N° 4
                      
                      This is the line N° 6 - This is the line N° 6 - This is the line N° 6
                      
                      ...
                      
                      ...
                      
                      This is the line N° 4 - This is the line N° 4 - This is the line N° 4
                      
                      This is the line N° 6 - This is the line N° 6 - This is the line N° 6
                      
                      • To begin with, recopy your File_1 file as File_All

                      • Open the two files File_All and File_2 in Notepad++

                      • Move at the very beginning of the first NON empty line of File_2 ( should be right before the T of line 2 )

                      • Run the Edit > Begin/End Select option ( The option is automatically checked ! )

                      • By any means, move to the very end of the last NON empty line of File-2 ( should be right after the 6 of the last line )

                      • Hold down the Alt key and click with the left-mouse button

                      • Release the Alt key

                      • Run again the Edit > Begin/End Select option ( The option is automatically unchecked )

                      => After a while, you should get a rectangular selection of 5,999 × 69 characters

                      • Hit the Ctrl + C shortcut

                      • Switch to the File_All tab

                      • Move to the very first EMPTY line of File_All ( should be the line 2 )

                      • Hit the Ctrl + V shortcut

                      => After a while, you’ll get your expected text :

                      This is the line N° 1 - This is the line N° 1 - This is the line N° 1
                      This is the line N° 2 - This is the line N° 2 - This is the line N° 2
                      This is the line N° 3 - This is the line N° 3 - This is the line N° 3
                      This is the line N° 4 - This is the line N° 4 - This is the line N° 4
                      This is the line N° 5 - This is the line N° 5 - This is the line N° 5
                      This is the line N° 6 - This is the line N° 6 - This is the line N° 6
                      This is the line N° 1 - This is the line N° 1 - This is the line N° 1
                      This is the line N° 2 - This is the line N° 2 - This is the line N° 2
                      This is the line N° 3 - This is the line N° 3 - This is the line N° 3
                      This is the line N° 4 - This is the line N° 4 - This is the line N° 4
                      This is the line N° 5 - This is the line N° 5 - This is the line N° 5
                      This is the line N° 6 - This is the line N° 6 - This is the line N° 6
                      ...
                      ...
                      ...
                      This is the line N° 3 - This is the line N° 3 - This is the line N° 3
                      This is the line N° 4 - This is the line N° 4 - This is the line N° 4
                      This is the line N° 5 - This is the line N° 5 - This is the line N° 5
                      This is the line N° 6 - This is the line N° 6 - This is the line N° 6
                      
                      • Save the new contents of File_All

                      Here you are !

                      Best Regards,

                      guy038

                      Alan KilbornA 1 Reply Last reply Reply Quote 3
                      • Alan KilbornA
                        Alan Kilborn @guy038
                        last edited by Alan Kilborn

                        I noticed that the technique using the BetterMultiselection plugin described here: https://community.notepad-plus-plus.org/topic/22358/ Jan 8, 2022, 7:55 AM could also solve the problem of @0Raniere0 ; it may be very similar to @guy038’s solution presented directly above.

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