Page 1 of 1

Compare files across panes

Posted: 17 Sep 2009 18:15
by serendipity
I made this little script to compare one selected file in current pane with all files on other pane.
XY will come up with list of files that have same content as current selected file.

Download:
ComparePaneFiles.xys
(1.48 KiB) Downloaded 315 times

Code: Select all

//Compare one file with all files in other pane
 focus;
 END (<curitem>=="", "Select one file to compare with");
 $paneinfo1= getinfo(Pane);
 $file1= <curitem>;
 $name1=<curname>;
 $sourcesize= report("{size RAW}",1);
 $item1=readfile ($file1,b);
 copytext;
 copytext ("Pane#$paneinfo1: <crlf>Source File= $file1 <crlf><crlf>");
 $text1= <clipboard>;
 copytext;
 focus pi;
 
 $paneinfo2= getinfo(Pane);
 $allitems= getinfo ("CountItems");
 $path2= <curpath>;
 setting "HideFoldersInList",r;
 //sortby size, a;
 $items= getinfo ("CountItems");
 END ($items==0);
 $count=1;
 $found=0;
  

 WHILE ($count<=$items) {
 sel $count;
 $size= report("{size RAW}",1);

 IF ($size==$sourcesize) {
 $file2= <curitem>;
 $item2=readfile ($file2,b); 
 $compare= compare ($item1, $item2, "b");

 IF ($compare==0) {
 $found++;
 $FilePosition= getinfo (FocusedPos);
 $FilePosition= $FilePosition +($allitems-$items);
 copytext ("#$FilePosition= $file2<crlf>",a);  
  }
 ELSE {
  //nothing;
 }
 }
 ELSE {
  //skip item;
 } 
 $count++;
 }
 
 IF ($found=="0") {
 $text2= "Pane#$paneinfo2: <crlf>No files found!";
 }
 ELSE {
 $text2="Pane#$paneinfo2: <crlf>Files with same content= $found <crlf><crlf>On line number(s):";
 }
 $text3=<clipboard>;
 
 copytext "$text1 <crlf>$text2 <crlf>$text3 <crlf>"; 
 sel $FilePosition;
 status "Copied to Clipboard!";
 text <clipboard>,800,400, "Compare Pane-$paneinfo1 file: ""$name1"" with all Pane-$paneinfo2 files in ""$path2""",w;
 
 

Re: Compare files across panes

Posted: 28 Aug 2010 02:21
by SkyFrontier
Fixed version (spacing, only):

Code: Select all

//[url=http://www.xyplorer.com/xyfc/viewtopic.php?p=37281#p37281]Compare Files Across Panes[/url]
//Compare one file with all files in other pane
 focus;
  END (<curitem>=="", "Select one file to compare with");
  $paneinfo1= getinfo(Pane);
  $file1= <curitem>;
  $name1=<curname>;
  $sourcesize= report("{size RAW}",1);
  $item1=readfile ($file1,b);
  copytext;
  copytext ("Pane#$paneinfo1: <crlf>Source File= $file1 <crlf><crlf>");
  $text1= <clipboard>;
  copytext;
  focus pi;

  $paneinfo2= getinfo(Pane);
  $allitems= getinfo ("CountItems");
  $path2= <curpath>;
  setting "HideFoldersInList",r;
  //sortby size, a;
  $items= getinfo ("CountItems");
  END ($items==0);
  $count=1;
  $found=0;
 

  WHILE ($count<=$items) {
  sel $count;
  $size= report("{size RAW}",1);

  IF ($size==$sourcesize) {
  $file2= <curitem>;
  $item2=readfile ($file2,b);
  $compare= compare ($item1, $item2, "b");

  IF ($compare==0) {
  $found++;
  $FilePosition= getinfo (FocusedPos);
  $FilePosition= $FilePosition +($allitems-$items);
  copytext ("#$FilePosition= $file2<crlf>",a); 
    }
  ELSE {
  //nothing;
  }
  }
  ELSE {
  //skip item;
  }
  $count++;
  }

  IF ($found=="0") {
  $text2= "Pane#$paneinfo2: <crlf>No files found!";
  }
  ELSE {
  $text2="Pane#$paneinfo2: <crlf>Files with same content= $found <crlf><crlf>On line number(s):";
  }
  $text3=<clipboard>;

  copytext "$text1 <crlf>$text2 <crlf>$text3 <crlf>";
  sel $FilePosition;
  status "Copied to Clipboard!";
  text <clipboard>,800,400, "Compare Pane-$paneinfo1 file: ""$name1"" with all Pane-$paneinfo2 files in ""$path2""",w;