how to merge 2 files... seems simple enough right?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dankk
    Visitor
    • Aug 2010
    • 6

    how to merge 2 files... seems simple enough right?

    without overwriting text in the file I am writing to...

    I have over 11 password text files. Over the years they got scattered over different hard drives and networks. I am trying to put them all into one text file on my server now.

    I have read the help file for over an hour and looked through some of the forum, but haven't found an answer yet. Every time I try to merge 2 files, BC3 overwrite's the text of the file I am trying to merge to. This is extremely frustrating. I saw the 3-way merge option but don't know if that would apply to me as i am really aggravated right now and just want to accomplish what would seem to be an easy function. this used to be easy in BC2.

    BC3 compares so many different types of media now, that doing what it used to be good at, is now a major undertaking for the novice user it seems... Any help would be greatly appreciated.

    Thank you.
  • Aaron
    Team Scooter
    • Oct 2007
    • 15941

    #2
    Hello,

    Sorry to hear you are running into some trouble.
    The 2 way Text Compare is designed to open two files, and then save them after moving over changes. The easiest way to accomplish this would be to create a copy of your file and then save into the copy.

    You can also use the File menu -> Save File As instead of clicking the Save button. This works like most other text editors.

    Our BC3 Pro feature Text Merge is actually exactly what you are looking for. It defaults to a view that accepts two files, and shows a 3rd pane as an Output pane. This can be expanded to have 3 input panes and a 4th Output pane to perform a 3way Merge.
    Aaron P Scooter Software

    Comment

    • dankk
      Visitor
      • Aug 2010
      • 6

      #3
      ok, while you may have answered my question... I still dont understand.

      so i will try to spell this out in a simpler way:

      __________________________________________________ ___________
      text file 1 / line 1: username-password

      ok, now imagine that going on for 200 more lines with descriptions and such that span across multiple lines....

      text file 1 / line 1: "jimmy" uses username-password
      line 2: blah blah
      line 3: blah blah
      line 4: blah blah and blah /end "jimmy"
      __________________________________________________ ___________

      now text file 2 comes into play:

      text file 2 / line 1: DIFFERENT username-password

      now imagine this file going on and on for 200 or more lines as well

      text file 2 / line 1: did you see what "sally" said about this password...
      line 2: blah blah
      line 3: blah blah
      line 4: password / username /end "sally"
      __________________________________________________ ____________

      now here we are at where you said I can join these 2 files together...

      I dont want to lose what "sally" said on line 1,2,3,and 4 of text file 2 even though I still want the username/password of "jimmy" on line 1,2,3 and 4 to be saved as well in the same document.

      I have tried this in multiple ways... It just isnt working. maybe a step by step for the simple minded? I keep overwriting the text of the opposite file. VERY frustrating.. If the files text lines didnt match up exactly, it wouldnt be a problem, but they DO match up and i cant be bothered with changing and going through hundreds of lines of text for each file. that is what BC2 was for and now BC3... ughhh

      And yes, i know I am an idiot. thank you for any help with this.

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 15941

        #4
        So you have two files which are aligning pairs of lines, but you do not want to replace either line? You want to have both lines present in the final output?

        If two lines are aligned, Beyond Compare 3 has determined that those are the same line, but contain changes. To prevent this from happening, you will need to either:
        1) Alter you alignment settings
        2) use the right-click Isolate command to break the alignment manually.

        You can alter the alignment settings in the Session menu -> Session Settings -> Alignment. You can enable the option "Never align mismatches", which will prevent file 1line1 and file2line1 from matching as a pair. You can also try tweaking the other settings, such as turning off closeness matching or using the Alternate alignment method to see if they help improve results for your specific files.

        If you are still having trouble, please email a pair of example files to [email protected]. Also include your Support.zip (from the Help menu -> Support; Export) and a link back to this forum post.
        Aaron P Scooter Software

        Comment

        • dankk
          Visitor
          • Aug 2010
          • 6

          #5
          Im sorry, I was away for a few days...

          thank you very much for your reply and i will certainly try your recommendations...

          You actually did understand exactly what it is that I need to accomplish. While you may have given the appropriate and correct answer to solve the problem, it is WAY too difficult to come by when a "not-so-avid-user-of-this exact-program" is trying to employ this type of function via the programming available.

          a simple recommendation would be a one-click button to do things with text files like this... with all of the options in this program, it seems that this would be a cinch... *shrugs*

          i will report back to let you know if the "right-click Isolate command to break the alignment manually" suggestion actually works. thats a mouthful isnt it?

          Dankk

          Comment

          • dankk
            Visitor
            • Aug 2010
            • 6

            #6
            ok, here is the deal....

            while your suggestion may well work, it isn't easy and i still haven't been able to join two frikking text files together...

            should I just abandon BC3 and go back to BC2? I am a busy person and this optional crap is REALLY getting on my nerves.... Even "I" could write a basic program to put two files together with my extremely limited VB6, and Delphi programming knowledge.... i would sooner have the app complete than learn these options!

            This is just stupid.. over a week and all these options are moreso getting in the way than being of help!

            I guarantee you that more people are of my train of thought than the dedicated "help file" readers... Im sick of this. Make a one click solution!

            Comment

            • Chris
              Team Scooter
              • Oct 2007
              • 5533

              #7
              Hi Dan,

              If you just want to append one file to another, you can load the two files in the BC3 Text Compare. Right click on the first line of the right side file and select "Align With". Click past the last line of the left side file. This will align the text of the two files so they don't overwrite each other. Then use "Copy" to copy text between sides and do a save or "save as".

              This should be similar to Beyond Compare 2, only "Align With" in Beyond Compare 2 was called "Align Manually".
              Chris K Scooter Software

              Comment

              • Chris
                Team Scooter
                • Oct 2007
                • 5533

                #8
                For simple appending to an existing file, you can also use the command prompt:

                type a.txt >> b.txt

                Type lists the contents of a.txt, the >> operator appends the output of type to the end of b.txt.
                Chris K Scooter Software

                Comment

                • dankk
                  Visitor
                  • Aug 2010
                  • 6

                  #9
                  no, I dont want to append. A simple copy and paste of the contents of the entire file can also do that. (which almost sounds better than this headache, one loooooooong file with 15 repeats of the same thing in it.... lolol)

                  I want to join the files and only add the differences... I finally have the time to sit down again and am just as frustrated as before. I did the session menu/session settings/alignment and even then this program cant do the simple task of adding the "different" lines to a new line in the merged output and move down the list. They get overwritten.

                  this program reminds me of real player in the late 90's and early 2000 years... did everything but play music after a while.

                  Comment

                  • Aaron
                    Team Scooter
                    • Oct 2007
                    • 15941

                    #10
                    Did you try the Never Align Mismatches option I mentioned above? That combined with the Display Filter to Only Show Differences would show only different lines and would not allow anything to partially match. Use the Text Compare session type to mirror BC2 behavior.
                    Aaron P Scooter Software

                    Comment

                    • dankk
                      Visitor
                      • Aug 2010
                      • 6

                      #11
                      Thank you Aaron,

                      yes I am using the, "Never align differences" option.

                      I see the differences without the need of any filtering...

                      the only problem now is that no matter how i set it up (I am likely in the wrong place), I puts the differences in the *.txt files on the very next line. And I have to save the merged file and then go and manually add lines to give some space between the different lines.. (does that make sense?)

                      Example:

                      merged_file.txt

                      1. text
                      2. <space i have to manually add here after saving the merged file>
                      3. text

                      other than this.. I am getting the merging to happen. thank you.. this would have taken me literally days to do.

                      Comment

                      • Michael Bulgrien
                        Carpal Tunnel
                        • Oct 2007
                        • 1772

                        #12
                        Originally posted by dankk
                        I have to save the merged file and then go and manually add lines to give some space between the different lines.. (does that make sense?)
                        That is because the blank lines in each file perfectly match each other and align with each other.

                        Left File:
                        leftline1
                        blank line
                        leftline2
                        blank line
                        leftline3

                        etc.

                        Right File:
                        rightline1
                        blank line
                        Rightline2
                        blank line
                        Rightline3

                        etc.

                        Merged File:
                        leftline1
                        rightline1
                        aligned blank lines
                        leftline2
                        rightline2
                        aligned blank lines
                        leftline3
                        rightline3

                        etc.

                        Since BC3 compares on a line-by-line basis, there is really no way around this. In other words, even if you create a multi-line grammar to include the blank line with the preceding text in a single grammar element, BC3 will still mismatch the text and align the blank lines instead of treating the whole multi-line element as different and grouping the entire element (text and following blank line) separately on each side.

                        I would suggest opening the merged file in another editor (UltraEdit for example) and performing a Perl regular expression find and replace:

                        Find: (\r\n)+
                        Replace with: \r\n\r\n

                        This would ensure that every line is followed by exactly two carriage return/life feeds (exactly one blank line)
                        Last edited by Michael Bulgrien; 13-Sep-2010, 07:19 PM.
                        BC v4.0.7 build 19761
                        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                        Comment

                        • dankk
                          Visitor
                          • Aug 2010
                          • 6

                          #13
                          Thanks for the useful comment... It isn't something that I need to do since I can zing through it ("it" being the merged files I just finished...) pretty quick without worrying about that.. Mine was a simple need. I think BC3 is just plain too much for such things.

                          This is fine if that is the purpose of BC dev's (to do more complicated things exclusively)... If not, this should be addressed by a wizard or something for those that don't have time to learn how to do this sort of thing. Just some thoughts...

                          The bottom line is the help from this forum -minus the DOS command- was very useful. Thanks for the help. I still prefer BC2.

                          Comment

                          • Michael Bulgrien
                            Carpal Tunnel
                            • Oct 2007
                            • 1772

                            #14
                            What is it, exactly, that you prefer about BC2?

                            BC3 adds a whole lot of new functionality including full screen editing and a 3-way merge session. The 3-way merge session is specifically for merging two different versions of the same file using a common ancestor (an older version of the file from which both newer versions evolved). The merge session analyzes both files against the common ancestor to automatically determine what changes were made to each file. The merge session then applies both sets of changes to the common ancestor to create a new merged file that contains a combination of all changes from both files.

                            A 3-way merge is most often used with source control/version management software that archives versioned copies of source files. A 3-way merge can only be expected to work smoothly when the center file is actually a common ancestor. Using a merge session to compare 3 different current iterations of a file (without a common ancestor) may generate unexpected results. It does not sound like you have a common ancestor for your password files. It sounds like you just have different versions of a file which have all evolved differently over time. If a 3-way merge session doesn't work for this task, don't use it. Use a 2-way file compare just as you would have in BC2.
                            BC v4.0.7 build 19761
                            ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                            Comment

                            Working...