How to Check Both Panes for Existing Files?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: How to Check Both Panes for Existing Files?

Post by Stefan »

Basic script would be f.ex. like:

Code: Select all

$ITEM = "<curname>";
  $OtherPane = get("path", i);

  if (exists("$OtherPane\$ITEM")==1)
  { 
      echo "Yes, file $ITEM exist on other pane too."; 
      //do more actions here
  }
  elseif(exists("$OtherPane\$ITEM")==2)
  {
      msg "$ITEM exists as folder.";
      //do more actions here
  }
  else
  {
      msg "$ITEM not found on other Pane";
      //do more actions here
  }

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

Re: How to Check Both Panes for Existing Files?

Post by admin »

Stefan wrote:Basic script would be f.ex. like:

Code: Select all

$ITEM = "<curname>";
  $OtherPane = get("path", i);

  if (exists("$OtherPane\$ITEM")==1)
  { 
      echo "Yes, file $ITEM exist on other pane too."; 
      //do more actions here
  }
  elseif(exists("$OtherPane\$ITEM")==2)
  {
      msg "$ITEM exists as folder.";
      //do more actions here
  }
  else
  {
      msg "$ITEM not found on other Pane";
      //do more actions here
  }
Again categories are being mixed. :roll: The function exists() does not tell whether an item exists on a pane (but in the file system). If the pane is e.g. visually filtered it does not "exist" on that pane.

But then I have no idea what the OP tries to achieve... so I better leave this thread... :)

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

Re: How to Check Both Panes for Existing Files?

Post by SkyFrontier »

@Stefan (or anyone interested on this):
The thing is:
Pane 1:

Code: Select all

text.diz = get its basename.
Pane 2:

Code: Select all

           = is text.diz here? No.
text.txt = but it has this one! (=same basename!) so ok - script will apply to this item; if text.diz were present too, both files should be affected.

Code: Select all

no text.txt nor test.diz = stop script.
Thanks for trying!
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...

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

Re: How to Check Both Panes for Existing Files?

Post by SkyFrontier »

...and I believe THIS VARIATION will solve the problem!!! :mrgreen:
($item is now <curbase> and elseif(exists("$OtherPane\$ITEM")==0)

Code: Select all

$ITEM = "<curbase>";
  $OtherPane = get("path", i);

  if (exists("$OtherPane\$ITEM")==1)
  {
      echo "Yes, file $ITEM exist on other pane too.";
      //do more actions here
  }
  elseif(exists("$OtherPane\$ITEM")==0)
  {
      msg "$ITEM exists as folder.";
      //do more actions here
  }
  else
  {
      msg "$ITEM not found on other Pane";
      //do more actions here
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...

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: How to Check Both Panes for Existing Files?

Post by Stefan »

admin wrote:
Stefan wrote:Basic script would be f.ex. like:

Code: Select all

$ITEM = "<curname>";
  $OtherPane = get("path", i);

  if (exists("$OtherPane\$ITEM")==1)
  { 
      echo "Yes, file $ITEM exist on other pane too."; 
      //do more actions here
  }
  elseif(exists("$OtherPane\$ITEM")==2)
  {
      msg "$ITEM exists as folder.";
      //do more actions here
  }
  else
  {
      msg "$ITEM not found on other Pane";
      //do more actions here
  }
Again categories are being mixed. :roll: The function exists() does not tell whether an item exists on a pane (but in the file system). If the pane is e.g. visually filtered it does not "exist" on that pane.
Ahh, thanks for that explanation, i never thought about this :wink:

Maybe this should be reflected in the help:
exists()
Checks whether a file or directory exists on the file system (Must not be visible on an pane).
Name: listpane
Action: Lists the visible contents of a (even filtered) pane.


Now i understood why listpane() was introduced :D

Code: Select all

$ITEM = "<curname>";

   $Result = listpane(i, $ITEM, 5); //check for file
   if ($Result == "")
   {
      $Result = listpane(i, $ITEM, 6); //check for folder
      if ($Result == "")
      {  
         msg "$ITEM not found on other Pane";
      }
      else
      {
         msg "$ITEM exists as folder.";
      }
   }
   else
   {
         msg "Yes, file $ITEM exist on other pane too."; 
   }

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

Re: How to Check Both Panes for Existing Files?

Post by admin »

Stefan wrote:Now i understood why listpane() was introduced :D

Code: Select all

$ITEM = "<curname>";

   $Result = listpane(i, $ITEM, 5); //check for file
   if ($Result == "")
   {
      $Result = listpane(i, $ITEM, 6); //check for folder
      if ($Result == "")
      {  
         msg "$ITEM not found on other Pane";
      }
      else
      {
         msg "$ITEM exists as folder.";
      }
   }
   else
   {
         msg "Yes, file $ITEM exist on other pane too."; 
   }
Yep, you finally got it. :wink:

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

Re: How to Check Both Panes for Existing Files?

Post by SkyFrontier »

Problem solved.
Used some count values along with selfilter as a completely different approach. Now my script checks if a file exists (whatever "existence" means for a file :wink: ) and makes virtually impossible for an user to get into trouble.
Thanks for the ideas, guys!
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