Page 1 of 1

Show only the selected items

Posted: 10 Aug 2010 19:52
by admin
Here's a useful one-liner IMO to filter in what's selected (and name the filter "sel" to make it shorter in the tab caption):

Code: Select all

filter '"sel" ' . getinfo("SelectedItemsNames", "|");
UPDATE: From v9.70.0001 onwards you can do this (this quotes the individual patterns to avoid that items are selected who's name is a part of any of the other selected items):

Code: Select all

filter '"sel" ' . formatlist(getinfo("SelectedItemsNames", "|"), "q");

Re: Show only the selected items

Posted: 05 Nov 2010 20:29
by jjk
Cheers, Don.

But I just found an issue : I have in the same dir, a subdir "OOo" and some files like "CalcOOo1.zzz", "CalcOOo2.zzz", "CalcOOo3.zzz" and so on.
If "OOo" dir i selected, your script shows "OOo" dir (of course) but also all files of which the name contains "OOo", because filter matches on patterns, but not on exact name.

I'd like an option, at least in filter scripting, to match exact names.

Re: Show only the selected items

Posted: 05 Nov 2010 23:22
by Stefan
This code

Code: Select all

filter '"sel" ' . getinfo("SelectedItemsNames", "|");
use the selected item names un-quoted and so as pattern which select all items containing this pattern.

filter OOo

X:\OOo
X:\CalcOOo1.zzz
X:\CalcOOo2.zzz
X:\CalcOOo3.zzz



If we put the names of the selected item between quotes it should work better.

Please try this:

Code: Select all

filter '"sel" ' .  '"' . getinfo("SelectedItemsNames", """|""") . '"';
results in filter "OOo"

Re: Show only the selected items

Posted: 05 Nov 2010 23:34
by serendipity
Here is a toggle switch i often use. Place it in catalog or button:

Code: Select all

//Toggle between Selected items and All items
    $tab= tab(,"term");
    IF($tab Like "*|*") {
                              filter;
                               }
    ELSE{
           filter '"' . getinfo("SelectedItemsNames", """|""") . '"';
           }

Re: Show only the selected items

Posted: 05 Nov 2010 23:48
by serendipity
Sorry if I am hijacking this thread, but i thought this would be useful to someone.

Here is the opposite of the below script, i.e. Filter-out selected files:

Code: Select all

//Toggle between Unselected items and All items
  $tab= tab(,"term");
  IF($tab Like "*|*"){
  filter;
  sel i;
  }
  ELSE{
       sel i;
       filter '"' . getinfo("SelectedItemsNames", """|""") . '"';
      }



Re: Show only the selected items

Posted: 06 Nov 2010 09:54
by admin
Stefan wrote:If we put the names of the selected item between quotes it should work better.

Please try this:

Code: Select all

filter '"sel" ' .  '"' . getinfo("SelectedItemsNames", """|""") . '"';
results in filter "OOo"
Adventurous construct but works. :)

Re: Show only the selected items

Posted: 06 Nov 2010 12:07
by Stefan
I think "Filter by selected items" is an native file manager command
and is worth to become an build-in feature.

perhaps it fit to
"View > Current Tab > Filter by selected items"

Re: Show only the selected items

Posted: 06 Nov 2010 13:11
by PeterH
Stefan wrote: Please try this:

Code: Select all

filter '"sel" ' .  '"' . getinfo("SelectedItemsNames", """|""") . '"';
results in filter "OOo"
Isn't

Code: Select all

filter '"sel" ' .  '"' . ...
identical to

Code: Select all

filter '"sel" "' . ...
:?:

(And maybe better to read and understand - if I understood it correct :wink: )

Re: Show only the selected items

Posted: 06 Nov 2010 14:10
by Stefan
PeterH wrote:Isn't [...] identical to [...]:?:
Yes
(And maybe better to read and understand - )
I think not really, since it mixed up two things (filter name part and leading quote of first item) and making it only harder for novices to follow.
It's imho just an bluffer to show how pseudo skilled the coder want to be, so i avoid this. (*hopingIdo?*, at least i try) Think K.I.S.S.

Re: Show only the selected items

Posted: 06 Nov 2010 14:19
by admin
From ver9.70.0001 onwards you can do this:

Code: Select all

filter '"sel" ' . formatlist(getinfo("SelectedItemsNames", "|"), "q");
:)

Re: Show only the selected items

Posted: 06 Nov 2010 15:43
by Stefan
formatlist(), marvellous. (It's good to know the coder, isn't it?) :D

Re: Show only the selected items

Posted: 06 Nov 2010 19:42
by Stefan
Stefan wrote:filter '"sel" ' . '"' . getinfo("SelectedItemsNames", """|""") . '"';
admin wrote:From ver9.70.0001 onwards you can do this:

Code: Select all

filter '"sel" ' . formatlist(getinfo("SelectedItemsNames", "|"), "q");
:)
formatlist() works for me in that case. Thanks.



BTW, if someone want to lookup the base command getinfo()

Code: Select all

Change Log for the latest XYplorer BETA version (v9.40.0105, 31-aug-2010).
     * SC getinfo. Changed it to "get". "getinfo" is officially obsolete,
      but it is kept for back compatibility
:mrgreen: