Page 2 of 2

Re: How to search in all direct subfolders ie. NOT recursive

Posted: 08 Nov 2011 12:36
by TheQwerty
kotlmg wrote:can you please add search subfolders recursively to the above code. i.e the code should have two options i.e. 1. search non recursively and 2. search recursively.
But searching recursively is already easy enough to do in XY... the whole point of the script is to get around XY's shortcoming.

If you really want to change the behavior of the script then end your query with "/r" which will prevent the script from appending "/" and tells XY to search recursively.

EDIT: Before you insist...

Code: Select all

"Search Folders||1 : flat"
	// Try selected paths
	$location = Report('{Dir {FullName};||{FullName};}', 1);

	// If no selection: try listed paths.
	if (! IsSet($location) OR $location Like '') {
		$location = Report('{Dir {FullName};||{FullName};}');
	}

	// If none listed: use current path.
	if (! IsSet($location) OR $location Like '') {
		$location = "<curpath>";
	}


	// If no query provided: prompt user.
	Global($query);
	if (! IsSet($query) OR $query Like '') {
		$query = Input('Search Query', "Enter your search terms:<crlf><crlf>Note that if query does not contain '/' then it will be appended to prevent searching subfolders.", "$query");
	}

	// If no suffix found: default to non-recursive.
	Global($suffix);
	if (! IsSet($suffix) OR $suffix Like '') {
		$suffix = ' /';
	}

	// We add a suffix (typically '/' or '/r') to the query
	// if it isn't already there to control XY's search behavior..
	$query = RegexReplace("$query", '^([^/]*)$', "$1$suffix");

	// Perform quick search.
	Goto "$location?$query";

"Search Folders Recursively : recurse"
	Global($suffix);
	$suffix = ' /r';
	Sub('flat');
The alias we set up in the previous post will now display a menu to select how deep you want to venture down the rabbit hole. To proceed with a renewed haste add the labels to the loads.

Code: Select all

@search=Global($query);$query="<@0>";Load('SearchSubfolders.xys');
@flatSearch=Global($query);$query="<@0>";Load('SearchSubfolders.xys', 'flat');
@recursiveSearch=Global($query);$query="<@0>";Load('SearchSubfolders.xys', 'recurse');

Re: How to search in all direct subfolders ie. NOT recursive

Posted: 08 Nov 2011 14:21
by kotlmg
thanks a lot sir, it is working.

Re: How to search in all direct subfolders ie. NOT recursive

Posted: 08 Nov 2011 16:35
by kotlmg
can you add the options of search within search results to your script?

Re: How to search in all direct subfolders ie. NOT recursive

Posted: 08 Nov 2011 16:43
by TheQwerty
No