Find on both folder & files - also return files in folders matched

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Millzey
Posts: 169
Joined: 07 Oct 2011 15:10

Find on both folder & files - also return files in folders matched

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

jupe
Posts: 3566
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Find on both folder & files - also return files in folders matched

Post by jupe »

I am a little confused :veryconfused: 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.

Millzey
Posts: 169
Joined: 07 Oct 2011 15:10

Re: Find on both folder & files - also return files in folders matched

Post 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

jupe
Posts: 3566
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Find on both folder & files - also return files in folders matched

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

Millzey
Posts: 169
Joined: 07 Oct 2011 15:10

Re: Find on both folder & files - also return files in folders matched

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

Millzey
Posts: 169
Joined: 07 Oct 2011 15:10

Re: Find on both folder & files - also return files in folders matched

Post by Millzey »

It finally finished and returned a list of 45,000 files of 45,000 files searched. Any idea what went wrong?

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Find on both folder & files - also return files in folders matched

Post 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?
One of my scripts helped you out? Please donate via Paypal

Millzey
Posts: 169
Joined: 07 Oct 2011 15:10

Re: Find on both folder & files - also return files in folders matched

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

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Find on both folder & files - also return files in folders matched

Post 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

Code: Select all

step;
above that first line.
Make sure that the resulting variable is NOT empty.
One of my scripts helped you out? Please donate via Paypal

Post Reply