Copy only difference (kdiff, winmerge, any diff like tool)
Asked Answered
T

6

19

Is there possibility of copy ONLY difference of two files? Like in winmerge, but, I can't find this optionenter image description here

Just like on this screen- i want to copy only 'yellow part' . Of course I can do that manually, but in big file it's not too funny :-)

Textbook answered 27/2, 2015 at 12:48 Comment(0)
H
28

WinMerge has a built-in and simple way to generate such "diff only" files, that they called "patches".

Click on "Tool", then on "Generate Patch...", and enter where you want to store the result:

enter image description here

You will obtain (for your example) the file

4,8c4,8
< HELLO WORLD
< HELLO WORLD
< HELLO WORLD
< HELLO WORLD
< HELLO WORLD
---
> 
> 
> 
> 
> 

That uses the standard, compact way of representing diff and is easy to manipulate.

Hodden answered 20/2, 2018 at 5:29 Comment(2)
Great answer, it helped me.Brinna
Style: Unified shows the +line -line .diff format.Lumbering
S
13

Here is how you do it in WinMerge:

  1. Disable any context lines: [View] > [Context] > [0 Lines].
  2. Select pane of interest: Click on pane.
  3. Select all text: [Edit] > [Select All] or [Ctrl]+[a].
  4. Copy selection: [Edit] > [Copy] or [Ctrl]+[c].
Simmer answered 9/3, 2018 at 15:34 Comment(0)
K
11

There is a free app called DiffMerge.

Note : The option 'Show differences only' will be disabled until you switch to the bottom tab labeled Referenced View(Files as loaded). After that you should be able to use Differences Only view.

Difference with content

Difference only

Kana answered 16/6, 2015 at 4:57 Comment(0)
T
3

In winmerge there is very nice feature- in tools you can generate raport in html by Tools-> Raport. After that operation you can parse generated html- and in that way get only differenece (but maybe it's not simplest solution)

Textbook answered 2/3, 2015 at 11:6 Comment(0)
C
1

Most diff tools have a patch generation functionality which can work toward the clipboard, this is mostly what you want as you will get only changed text on left and right side (if you remove the context lines). If you want only those of one side you can easily filter the patch with regard to the first character (removing all lines, using an editor, matching something like ^[+>].*$ to keep removed lines or ^[-<].*$ to keep added lines).

The diff tool in command line will output just that, piped with a grep and one of the above regular expression you are done.

Cladding answered 1/3, 2015 at 19:2 Comment(0)
B
-1

WinMerge offers the "Copy Left to..." or "Copy right to..." that will copy only the differences to a folder of choice.

Basel answered 8/10, 2015 at 17:36 Comment(4)
Where is that supposed to be?Basinet
Compare 2 similar directories.... then right click on the filelist and you'll see the "Copy Left To..." stuffBasel
Ok, and how is that supposed to address OP's question? You will copy files between folders, not compare their textual contents, I believe.Basinet
Sorry..I went based on the OP title.. not reading the actual content.Basel

© 2022 - 2024 — McMap. All rights reserved.