Show only the selected items

Discuss and share scripts and script files...
Post Reply
admin
Site Admin
Posts: 64886
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Show only the selected items

Post 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");

jjk
Posts: 202
Joined: 10 Oct 2007 20:11
Location: Paris

Re: Show only the selected items

Post 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.

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

Re: Show only the selected items

Post 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"

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Show only the selected items

Post 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", """|""") . '"';
           }

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Show only the selected items

Post 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", """|""") . '"';
      }



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

Re: Show only the selected items

Post 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. :)

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

Re: Show only the selected items

Post 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"

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Show only the selected items

Post 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: )

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

Re: Show only the selected items

Post 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.

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

Re: Show only the selected items

Post by admin »

From ver9.70.0001 onwards you can do this:

Code: Select all

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

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

Re: Show only the selected items

Post by Stefan »

formatlist(), marvellous. (It's good to know the coder, isn't it?) :D

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

Re: Show only the selected items

Post 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:

Post Reply