any option to find or filter out files by path ONLY

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
abc550
Posts: 38
Joined: 18 Feb 2010 09:46

any option to find or filter out files by path ONLY

Post by abc550 »

Hi,

I can not find the right approach to find and/or filter out only files, which contents the search string in the full path (folder or its parent etc. folders), but not in the filename itself. Say, I need to see all files, which are located in any folder, which name includes number "12345" - but except those files, which name itself conclude the part "12345".

My first idea was to use bulean search with the search option "Path" enabled and add a condition to exclude files with "12345" in the name. But actually it is nor possible to exclude only files this way.

Or if is not possible to search files by this criteria, may be I can filter them out in the found files list.

Thanks in advance!

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

Re: any option to find or filter out files by path ONLY

Post by highend »

I didn't check if it's possible with the normal search function but you could write a script to do what you want.

folderreport(), strpos()/gettoken() and a regexreplace() compare in a foreach loop would be needed to accomplish this.
One of my scripts helped you out? Please donate via Paypal

abc550
Posts: 38
Joined: 18 Feb 2010 09:46

Re: any option to find or filter out files by path ONLY

Post by abc550 »

Thank you, highend!

I'll try you solution. However as I'm not very comfortable with scripts, I'd prefer a "normal search" solution... if it is possible...

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

Re: any option to find or filter out files by path ONLY

Post by highend »

This should work:

Code: Select all

// Find files where the foldername contains something that the filename
// does not contain

	$input = input("Enter what a folder name must contain:");
	$list = folderreport("files", "r", , "r");
	$output = "";
	foreach($item, $list, "<crlf>") {
		$splitLeft = strpos($item, "\", -1);
		$leftString = substr($item, 0, $splitLeft);
		$rightString = substr($item, $splitLeft +1);
		$resultLeft = strpos($leftString, $input);
		$resultRight = strpos($rightString, $input);
		if($resultLeft != -1 && $resultRight == -1) {
			$output = $output . $item . <crlf>;
		}
	}
	if($output != "") {
		text $output;
	} else {
		msg "No files found!";
	}
It scans for all files recursively in the current directory.
One of my scripts helped you out? Please donate via Paypal

Post Reply