Page 1 of 1
Find on both folder & files - also return files in folders matched
Posted: 26 Nov 2018 02:51
by Millzey
Having a bit of trouble acomplishing a tweak to a search template I use every few minutes, that searches about two dozen locations recursively. Its just a simple keyword search.
I want the search term (keyword) to apply to folder names AND file names as usual, but also show the files included in those folders that were matched (recursivly of course). I guess this would have to in be a branch? But I can't come up with the possible switches I need to make it work. I'm starting to wonder if this is a limitation and could possibly be a future feature.
Any help appreciated!!!!
Re: Find on both folder & files - also return files in folders matched
Posted: 26 Nov 2018 03:10
by jupe
I am a little confused

at your request, so just to be clear, as well as files that match the keyword, you want folders that match against the keyword to show
all their contents in the search results, not just items matching the keyword?
If that is the case, you can do it, but AFAIK you would have to write a small script that gets the folder results from the first search and then gets the contents of those folders and adds them to the search results of the first search. ie. 2 searches and combined results.
Re: Find on both folder & files - also return files in folders matched
Posted: 01 Dec 2018 02:00
by Millzey
Yes that's what I was wanting. A switch to accomodate this with quick search and find files would be sweet.
I can probably handle the script with a little guidance. Do two seperate quicksearch's? How could I combine those two results in one list view, if that's even possible? I need to be able to drag the results to another program. I havent used report functions much so I dont know if thats the route I need. I'm thinking a paper folder is the only choice? If so, I would basically just have a designated paper folder that I overwrite each search?
Thanks for the reply and any help
Re: Find on both folder & files - also return files in folders matched
Posted: 01 Dec 2018 03:16
by jupe
Depending on your exact needs, something like this might suit what you want (adjust the top 2 variables to suit):
Code: Select all
$searchloc = "<curpath>";
$keyword = "XY";
$folders = quicksearch("/f", quicksearch("$keyword /d", $searchloc,,"s"),,"s");
$files = quicksearch("$keyword /f", $searchloc,,"s");
goto formatlist($folders . <crlf> . $files, "sde", <crlf>) . "?";
This is just a bare bones script, you could modify it to use a paperfolder if you wanted (and yes a rewriting a designated PF is the way), this is just to give you an idea of 1 of the many ways to accomplish it, it might need some fine tuning by you, if you decide to use it.
Re: Find on both folder & files - also return files in folders matched
Posted: 01 Dec 2018 21:56
by Millzey
Great thanks for the input.
So far my initial test using your example with a few paths defined for $searchloc delimited with a semicolon, and probably around 50k files searched using a single keyword with less than 50 actual matches has my xyplorer.exe at full cpu and unresponsive for about 10 minutes so far and using 400MB ram. But its still doing something as the memory usage is slightly fluctuating. I'll try to wait it out to maybe figure out what the hell its doing.
Re: Find on both folder & files - also return files in folders matched
Posted: 01 Dec 2018 22:03
by Millzey
It finally finished and returned a list of 45,000 files of 45,000 files searched. Any idea what went wrong?
Re: Find on both folder & files - also return files in folders matched
Posted: 01 Dec 2018 22:40
by highend
How many folders are in $searchloc?
How many subfolders exist (combined) for all $searchloc(s)?
Does each folder in $searchlog have the keyword in its name?
Re: Find on both folder & files - also return files in folders matched
Posted: 01 Dec 2018 23:26
by Millzey
I have 5 folders for $searchloc. A quick estimation of subfolders is 5000. None of the top level foldernames in $searchloc have the keyword.
The proper result should be a handful of files, and a match of a few folders (which each contain a few files each I'm trying to list in the results)
Re: Find on both folder & files - also return files in folders matched
Posted: 01 Dec 2018 23:46
by highend
If any of the quicksearches delivers an empty result the next quicksearch that uses the return value (the variable) of
that quicksearch, will search "everything" instead of only a handful of items.
So split the first two quicksearches into two lines with their own variable and put a
above that first line.
Make sure that the resulting variable is NOT empty.