XY + WinMerge

Discuss and share scripts and script files...
Walrez
Posts: 25
Joined: 05 May 2008 16:42

XY + WinMerge

Post by Walrez »

Not very elegant, but.... this one lets you select two of your open tabs, and opens WinMerge (a file synchronization program) with both directories loaded for comparison:
You need to adapt the location of WinMerge in your system.

"WinMerge:WinMerge"
#343;
set $first, <curpath>;
#343;
set $second, <curpath>;
set $cmd, """D:\Software\WinMergePortable\WinMergePortable.exe"" /e /r /f ""*.frm *.cls"" """;
addstr $cmd, $first, """ """, $second , """";
open $cmd;

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

Well, I don't use WinMerge, but I actually like the idea of using the Tab list that way, that's a nice idea :)
Proud XYplorer Fanatic

graham
Posts: 457
Joined: 24 Aug 2007 22:08
Location: Isle of Man

Post by graham »

I don't have winmerge but the approach is what I think could offer a sensible and elegant solution to the DP user need for file comparisons.

Taking this concept further ...

Rather than a complete integration of DP within existing code of XY this approach offers many possibilities for external programs to solve a special DP need. This is why I once remarked that for those wanting DP all that was required was a definition of the 'user needs'. It could be that these needs can be solved by calling (script?) an external written program or module to satisfy a particular need. It will not satisfy the die hard DP user who wants it all but there are DP programs out there that do this so why complicate XY tab principles for a few special needs. I urge Don to explore this approach as a very feasible solution to satisfy most DP wishes (90%) and the remaining 10% will have to revert to a DP only program.

Walrez
Posts: 25
Joined: 05 May 2008 16:42

Post by Walrez »

jacky wrote:Well, I don't use WinMerge, but I actually like the idea of using the Tab list that way, that's a nice idea :)
Here's a variation: This one sends the current tab and the next one. Of course, these scripts are useful for whatever external programs that can accept more than one file/path for whatever reason.

"WinMerge2:WinMerge2"
set $first, <curpath>;
seltab +;
set $second, <curpath>;
seltab -;
set $cmd, """D:\Software\WinMerge\WinMerge.exe"" /e /r /f ""*.*"" """;
addstr $cmd, $first, """ """, $second , """";
open $cmd;

eurytos
Posts: 200
Joined: 29 Jan 2008 15:53

Post by eurytos »

here is my 'open with' UDC that I have setup using winmerge.

"C:\Program Files\WinMerge\WinMergeU.exe" "<items>" "<clipboard>"


It will work comparing files or folders. I used the clipboard so I would not be required to be in the same tab to do comparisons but that causes an issue if comparing large directories. Overall it works well for me though.


I should probably improve it by using some scripting. maybe I will do that now.

admin
Site Admin
Posts: 60288
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Post by admin »

eurytos wrote:here is my 'open with' UDC that I have setup using winmerge.

"C:\Program Files\WinMerge\WinMergeU.exe" "<items>" "<clipboard>"


It will work comparing files or folders. I used the clipboard so I would not be required to be in the same tab to do comparisons but that causes an issue if comparing large directories. Overall it works well for me though.


I should probably improve it by using some scripting. maybe I will do that now.
Why "<items>"? (= all selected items) More suitable would be <curitem> (= the one selected and focused item).

eurytos
Posts: 200
Joined: 29 Jan 2008 15:53

Post by eurytos »

admin wrote:
eurytos wrote:here is my 'open with' UDC that I have setup using winmerge.

"C:\Program Files\WinMerge\WinMergeU.exe" "<items>" "<clipboard>"


It will work comparing files or folders. I used the clipboard so I would not be required to be in the same tab to do comparisons but that causes an issue if comparing large directories. Overall it works well for me though.


I should probably improve it by using some scripting. maybe I will do that now.
Why "<items>"? (= all selected items) More suitable would be <curitem> (= the one selected and focused item).
Using "<items>" gives me the ability to also select two items/folders in the same tab without needing to copy one to the clipboard. I don't think that would work if I used <curitem>

admin
Site Admin
Posts: 60288
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Post by admin »

eurytos wrote:
admin wrote:
eurytos wrote:here is my 'open with' UDC that I have setup using winmerge.

"C:\Program Files\WinMerge\WinMergeU.exe" "<items>" "<clipboard>"


It will work comparing files or folders. I used the clipboard so I would not be required to be in the same tab to do comparisons but that causes an issue if comparing large directories. Overall it works well for me though.


I should probably improve it by using some scripting. maybe I will do that now.
Why "<items>"? (= all selected items) More suitable would be <curitem> (= the one selected and focused item).
Using "<items>" gives me the ability to also select two items/folders in the same tab without needing to copy one to the clipboard. I don't think that would work if I used <curitem>
Ah, I see! And what if you select two items and there's something on the clipboard? How does winmerge handle this?

eurytos
Posts: 200
Joined: 29 Jan 2008 15:53

Post by eurytos »

admin wrote:
eurytos wrote:
admin wrote:
eurytos wrote:here is my 'open with' UDC that I have setup using winmerge.

"C:\Program Files\WinMerge\WinMergeU.exe" "<items>" "<clipboard>"


It will work comparing files or folders. I used the clipboard so I would not be required to be in the same tab to do comparisons but that causes an issue if comparing large directories. Overall it works well for me though.


I should probably improve it by using some scripting. maybe I will do that now.
Why "<items>"? (= all selected items) More suitable would be <curitem> (= the one selected and focused item).
Using "<items>" gives me the ability to also select two items/folders in the same tab without needing to copy one to the clipboard. I don't think that would work if I used <curitem>
Ah, I see! And what if you select two items and there's something on the clipboard? How does winmerge handle this?
It takes the first two items and then ignores the clipboard (or at least don't give me a visible error). The functionality wouldn't work the same if I swapped <clipboard> and <items>, then it would take the clipboard and 1 item.

leinad
Posts: 47
Joined: 17 Jun 2010 09:08

Re: XY + WinMerge

Post by leinad »

Just for the record, to compare two selected files in the active pane, here is a one-liner:

Code: Select all

::run """C:\Programme\WinMerge\WinMergeU.exe"" /e /r ""<get SelectedItemsPathNames """""" """""">""";
and to compare two files which are in a different pane

Code: Select all

::run """C:\Programme\WinMerge\WinMergeU.exe"" /e /r ""<get item 1>"" ""<get item 2>""";

admin
Site Admin
Posts: 60288
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: XY + WinMerge

Post by admin »

leinad wrote:Just for the record, to compare two selected files in the active pane, here is a one-liner:

Code: Select all

::run """C:\Programme\WinMerge\WinMergeU.exe"" /e /r ""<get SelectedItemsPathNames """""" """""">""";
This looks so frightening that I think about adding something like SelectedItemsPathNamesAsQuotedItemsList... :)

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: XY + WinMerge

Post by highend »

SelectedItemsPathNamesAsQuotedItemsList...
Don't steal me my usual
formatlist()

^^
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: XY + WinMerge

Post by Enternal »

Just an "update" to the code here. Well too bad it's not a one-liner but at least you can now select either files from the same pane or a single file from each pane to compare. And it does it smartly too so if you selected 2 files in the current pane, it will compare those. If you select only 1 file, it will look for another selected item in the other pane and compare the 2. If you selected more than 2 files on the same pane, it will throw you an error. If you selected 1 but more than 1 file on the other pane (total more than 2), it will also throw an error.

Code: Select all

"WinMerge"
  $Executable = "C:\Users\Owner\Programs\Other\WinMerge\WinMergePortable.exe";
  End ("<selitems>"==""),"Nothing Is Selected!";
  If Get("CountSelected") == 1 {
      $Count1 = Get("CountSelected", "1"); $Count2 = Get("CountSelected", "2");
      If ($Count1 > 1 || $Count2 > 1) {Msg "No More Than 2 Items can Be Selected!"; End(1);}
      Else {$SelectedItems = "<get item 1>|<get item 2>";} }
  ElseIf Get("CountSelected") > 2 {Msg "No More Than 2 Items can Be Selected!"; End(1);}
  Else {$SelectedItems = Get("SelectedItemsPathNames","|");}
  $File1 = GetToken("$SelectedItems",1,"|"); $File2 = GetToken("$SelectedItems",2,"|");
  Run """$Executable"" /e /r ""$File1"" ""$File2"""; }

"BeyondCompare"
  $Executable = "C:\Users\Owner\Programs\Other\Beyond Compare\BCompare.exe";
  End ("<selitems>"==""),"Nothing Is Selected!";
  If Get("CountSelected") == 1 {
      $Count1 = Get("CountSelected", "1"); $Count2 = Get("CountSelected", "2");
      If ($Count1 > 1 || $Count2 > 1) {Msg "No More Than 2 Items can Be Selected!"; End(1);}
      Else {$SelectedItems = "<get item 1>|<get item 2>";} }
  ElseIf Get("CountSelected") > 2 {Msg "No More Than 2 Items can Be Selected!"; End(1);}
  Else {$SelectedItems = Get("SelectedItemsPathNames","|");}
  $File1 = GetToken("$SelectedItems",1,"|"); $File2 = GetToken("$SelectedItems",2,"|");
  Run """$Executable"" /e /r ""$File1"" ""$File2"""; }

Stef123

Re: XY + WinMerge

Post by Stef123 »

Whoa, thanks a lot. :tup:
This is much more versatile than my own clunky solution. And I learned some valuable scripting stuff as well. This deserves a permanent place in the scripts overview, imo. :beer:

klownboy
Posts: 4089
Joined: 28 Feb 2012 19:27

Re: XY + WinMerge

Post by klownboy »

Thanks Enternal, I just DL'ed WinMerge to give this a try.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Post Reply