Community
    • Login

    Merge 2 Ascii Files in one

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    10 Posts 6 Posters 1.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.
    • king_beloveK
      king_belove
      last edited by

      I got multiple Ascii Files from my WinCC OA programm and I want to merge them in one so I dont have to Import all one by one. Is there any possibilite to merge them together?

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

        Hello, @king_belove and All,

        The best way to merge any number of files in a single file is to follow these steps :

        • Create a new directory on your machine, called, for instance, Test_Merge

        • Copy all the files, to be merged, in the Test_Merge folder ( Note that these files can come from different directories ! )

        • Then, open a DOS prompt window

        • Type and valid the DOS command cd /d \Test_Merge

        • Verify with a simple DOS command dir that the Test_Merge folder does contain all your desired files

        • Now, type and valid the DOS command copy * Total.txt, with a space BEFORE and AFTER the star symbol

        • Start Notepad++

        • Open the ..\Test_Merge\Total.txt file

        • Go to the very end of the file ( Ctrl + End )

        • Delete the single SUB character

        • Save the Total.txt file

        Here you are !

        Best Regards

        guy038

        king_beloveK mkupperM 2 Replies Last reply Reply Quote 3
        • king_beloveK
          king_belove @guy038
          last edited by

          @guy038Thanks for your fast answer it worked

          PeterJonesP 1 Reply Last reply Reply Quote 1
          • PeterJonesP
            PeterJones @king_belove
            last edited by

            @king_belove ,

            If you were asking how to merge files in general, then Guy’s method will obviously work – however, it’s off topic for a Notepad++ forum (even though, in most circumstances, it’s probably more efficient to try to do the merge outside of Notepad++, as was shown).

            If you were asking how to merge files inside Notepad++, then the off-topic answer doesn’t actually meet the requirements. There is apparently a Merge files in one plugin available through Notepad++'s Plugins > Plugins Admin, which may or may not meet your needs (I’ve never used it, so I cannot say whether it would meet your needs or not). Or one could write their own script for the PythonScript or similar scripting plugin, if one knew one of the available scripting languages.

            Please remember to keep questions and answers focused on Notepad++ (and to only answer with the details of a non-Notepad++ solution if it’s is, to your knowledge, impossible to do inside of Notepad++).

            mkupperM king_beloveK 2 Replies Last reply Reply Quote 0
            • guy038G
              guy038
              last edited by guy038

              Hello, @king_belove, @peterjones and All,

              @peterjones said :

              If you were asking how to merge files in general, then Guy’s method will obviously work – however, it’s off topic for a Notepad++ forum (even though, in most circumstances, it’s probably more efficient to try to do the merge outside of Notepad++, as was shown).

              Ah my bad ! Sorry, peter, but I wanted to talk about this simple DOS method that very few people think of, at first !

              BR

              guy038

              1 Reply Last reply Reply Quote 0
              • mkupperM
                mkupper @PeterJones
                last edited by

                @PeterJones You can do it from inside Notepad++ by selecting Run / Run..., type cmd followed by <Enter key> and then follow @guy038 's directions…

                As there are no built-in Notepad++ features to merge or combine files we either show ways the issue can be solved to do it using things that come with Windows, show how is can be done using a third party tool (which may be a Notepad++ plugin), or say we can’t provide help.

                I personally am more of fan of using the command prompt’s type command and redirecting the output to the combined file using >> Here’s an example that also prefaces each file in the combined result with a // style comment containing the file name being merged into the combined file:

                rem Clear the combined.txt file
                cd . >%TEMP%\combined.txt
                
                rem Merge all of the txt files in "c:\WinCC OA" into combined.txt
                for %i in ("c:\WinCC OA\*.txt") do (echo // ---- %~fi ---- >>%TEMP%\combined.txt & type "%i" >>%TEMP%\combined.txt)
                
                rem Walk the directory tree starting at "c:\WinCC OA" and merge all of *.txt into combined.txt
                for /R "c:\WinCC OA" %i in (*.txt) do (echo // ---- %~fi ---- >>%TEMP%\combined.txt & type "%i" >>%TEMP%\combined.txt)
                
                rem Open combined.txt in Notepad++ (assuming .txt is mapped to Notepad++)
                start %TEMP%\combined.txt
                
                1 Reply Last reply Reply Quote 1
                • mkupperM
                  mkupper @guy038
                  last edited by

                  @guy038 If you use copy /B ... then copy will run in binary mode and won’t append the Ctrl-Z or SUB at the end of the file.

                  To steer this back into Notepad++, I am wondering why @king_belove is seeking a combined file when Notepad++ has the ability to search in all opened files, to search/replace in all opened files, etc. One minor annoyance is that Notepad++ does not seem to offer mark in all opened files. There have been times where I constructed a combined file and opened that plus opened all of the files in Notepad++ so that I could do the marking in the combined file and then search/replace in all files if the marked text matches what I expected the search to hit.

                  1 Reply Last reply Reply Quote 3
                  • king_beloveK
                    king_belove @PeterJones
                    last edited by

                    PeterJones This Plugin is just for 2 files and still didnt work

                    1 Reply Last reply Reply Quote 0
                    • DoğancanD
                      Doğancan
                      last edited by PeterJones

                      https://community.notepad-plus-plus.org/topic/24872/is-there-any-alternative-to-merge-files-in-one-plugin?_=1694546136257

                      1 Reply Last reply Reply Quote 1
                      • Mark OlsonM
                        Mark Olson
                        last edited by

                        A proposal to clarify posts like this, so that people don’t waste time solving the wrong problem:

                        • use the word concatenate to refer to the process of taking a bunch of things and adding them one-after-the-other.
                        • use the word merge to refer to the process of taking a bunch of things and putting them together so that they overlap.

                        For example, the link Doğancan posted above goes to a thread where I made a tool to merge files (examples in that thread).

                        What everyone has been discussing above appears concatenation and should be labeled as such.

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