Page 1 of 2

SC Quicksearch - list search misses folders?

Posted: 10 Nov 2015 09:19
by Papoulka
I need quicksearch() to search a list of folders described in "ListToSearch.txt". Eg. I want to find all that have "mata" in their name. BTW I must use quicksearch because I want to add fuzziness after I get the basics working.

My code is:

Code: Select all

$list = readfile("C:\Temp\ListToSearch.txt");
  text quicksearch("mata", $list);
or from the address bar:

Code: Select all

::text quicksearch("mata", readfile("C:\Temp\ListToSearch.txt"));
If "ListToSearch.txt" contains the name of a text file:
  • c:\temp\mata.txt
the result as expected is "c:\temp\mata.txt".

But if "ListToSearch.txt" contains only the name of a folder:
  • c:\temp\mata

the result is empty - not as expected.
Quicksearch does not find the folder "mata" in the list.

I've tried everything I can think of. Any ideas?

Re: SC Quicksearch - list search misses folders?

Posted: 10 Nov 2015 09:39
by highend
Looks like a bug when using Search-In-List.
When you add a second item to the ListToSearch.txt file that is not that folder, the "mata" folder is found..

Re: SC Quicksearch - list search misses folders?

Posted: 10 Nov 2015 10:01
by Papoulka
Thanks for confirming that, highend. I wasn't sure it was a bug but ran out of ideas.

Following your observation - if the search list file contains a filename in addition to the folder names, QS succeeds. The problem seems limited to search lists comprising only folder names - which of course is what I am trying to use.

Until this is fixed, I may be able to work around it by adding a dummy filename.

Re: SC Quicksearch - list search misses folders?

Posted: 14 Nov 2015 15:23
by admin
Not a bug but works as advertised: Folders in Search-In-List are recursed just as in a multi-location search. They are not checked against the search pattern.

Re: SC Quicksearch - list search misses folders?

Posted: 15 Nov 2015 18:27
by Papoulka
OK, now I understand. I can suggest a small improvement in the Help for SIL. It currently says:
This list can contain files (they are directly checked against the search filters) and folders (they are recursed like in a normal (multi-)location search).
Add a following sentence: "Note: this means it can only search for files; not for folders".

I got confused because:
(a) I wanted to believe that SIL would find folders too ["The list can contain ... folders"].
(b) Most searches in XY can find files or folders.
(c) The rest of the text often refers to finding "items", which in XY usually means files, folders etc.
(d) It seemed like SIL *would* find folders, if there was at least one filename in the list.

This is rather a special case, so it could use a very clear note.

Re: SC Quicksearch - list search misses folders?

Posted: 15 Nov 2015 19:16
by admin
IMO the current description is sufficient. (And your suggestion "Note: this means it can only search for files; not for folders" is wrong: it can find folders, if they are within the passed search locations.)

Re: SC Quicksearch - list search misses folders?

Posted: 15 Nov 2015 21:07
by Papoulka
Then please give an example of how to use quicksearch() to find folders but no files. Adding it to the Examples list in the Help would also be useful, as it is not easy to figure out.

Thanks

Re: SC Quicksearch - list search misses folders?

Posted: 16 Nov 2015 05:31
by eil
@Papoulka seems like you're talking about same thing i asked here.
to solve same problem i had to make an additional brick of code to check is passed item is a folder and check them one by one. files and the insides of these folders will be handled by SIL, but true - first level folders are "skipped". :(

Re: SC Quicksearch - list search misses folders?

Posted: 16 Nov 2015 07:36
by bdeshi
Papoulka wrote:Then please give an example of how to use quicksearch() to find folders but no files
it's basic really; just use the folders-only flag:

Code: Select all

text quicksearch('* /d');
which will find all folders in current location. No "brick of code" required! :kidding:

Read more about quicksearch: ::rtfm 'idh_quicknamesearch.htm';
Adding more examples to quicksearch()'s description is a bit redundant, since a link to the syntax is already provided there.

Re: SC Quicksearch - list search misses folders?

Posted: 16 Nov 2015 15:25
by Papoulka
@Sammay - does that work for you in SIL? That's the question at hand.

@eil - You're right... your thread was on the same issue. But from the title I didn't realize it.

Re: SC Quicksearch - list search misses folders?

Posted: 16 Nov 2015 15:45
by bdeshi
uh, yes.

Code: Select all

text quicksearch('* /nd', listfolder(,,,';'));
lists folders in current list.

Regarding your original issue that quicksearch('pattern', 'a folder') doesn't match, it's because a single source folder is taken as the location to search in, so the folder itself is excluded (because it has become the parent location)
However, when the source is one or more items, [quicksearch('pattern', 'a folder;another item')] they are considered the items to search within, so any folder in the source matches.(the source param has become the (virtual) parent location)

(Don might want to explain this fact better in the docs.)

edited.

Re: SC Quicksearch - list search misses folders?

Posted: 16 Nov 2015 16:17
by eil
SammaySarkar wrote:it's basic really; just use the folders-only flag:

Code: Select all

text quicksearch('* /d');
which will find all folders in current location. No "brick of code" required! :kidding:
not really.) it's already SIL1(as usual) + SIL2(with flag for folders) + combine results in paper folder = because i want script to be universal and find everything without case if there is one folder in pattern or more. :P
SammaySarkar wrote:Regarding your original issue that quicksearch('pattern', 'a folder') doesn't match, it's because a single source folder is taken as the location to search in, so the folder itself is excluded (because it has become the parent location)
that's the point of misunderstanding: when you select just one folder its obvious to become "virtual", but when you selected(stated) i big list of items you don't expect anything to skip.

Re: SC Quicksearch - list search misses folders?

Posted: 16 Nov 2015 16:25
by admin
Yes, I see that point. But changing this behavior would mean to break old code.

I will add a new switch to this effect: Check the folder(s) passed as search location against the search criteria. (Note that in case of a resursive search, a folder will also be recursed if it does NOT match the pattern. Okay?)

Re: SC Quicksearch - list search misses folders?

Posted: 16 Nov 2015 17:42
by Papoulka
Good idea.

Re: SC Quicksearch - list search misses folders?

Posted: 16 Nov 2015 21:13
by eil
admin wrote: (Note that in case of a resursive search, a folder will also be recursed if it does NOT match the pattern. Okay?)
if this means <i'm using SIL on 15 files and 1(or 3) folders and both, folders and their subs, are checked> i'm both hands up to it.!