Compare files across panes

Discuss and share scripts and script files...
Post Reply
serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Compare files across panes

Post 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 274 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;
 
 

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Compare files across panes

Post 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;
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Post Reply