Page 1 of 2

New search pattern switch

Posted: 19 Jul 2020 13:34
by oXYgen
XYplorer has the /p switch that is used in the Find Files/Quick Search modes and returns the parent folders of all matching items. It is useful but not powerful because sometimes "parent" is not a direct container but implies a top-level folder. Suppose we search *.jpg in the "Root" location and want to perform some operations on the highlighted folders:

Root\
	User1\
		Photos\
			IMG_9022.JPG
	User2\
		Downloads\
			2020\
				February\
					Windows.jpg
				July\
					XY1950FP_t.jpg
				November\
					Test.zip
	User3\
		Software\
			Calculator.exe

I suggest to make a new switch called /parentdepth (or different name) that can accept a numeric parameter. For example, /parentdepth=1 would find "User1" and "User2" folders only. /parentdepth=2 would find "Photos" and "Downloads" folders only. /parentdepth=8 would act as /p switch returning "Photos", "February" and "July" parent folders. /parentdepth might have a shortcut /pd.

Re: New search pattern switch

Posted: 19 Jul 2020 14:56
by klownboy
I haven't tried it, but have you tried combining the /p switch with the /maxdepth=n switch?

Re: New search pattern switch

Posted: 19 Jul 2020 15:34
by oXYgen
klownboy wrote: 19 Jul 2020 14:56 I haven't tried it, but have you tried combining the /p switch with the /maxdepth=n switch?
It is a different case. /maxdepth limits the depth of recursion into child folders when searching, so /p /maxdepth=1 does not find anything in the example above. Furthermore, /maxdepth could be combined with /parentdepth to reduce the amount of items found.

Re: New search pattern switch

Posted: 19 Jul 2020 18:10
by klownboy
OK sorry, I think I understand now. From your example your return doesn't care whether *.jpg files are in a particular folder only that they exists somewhere in the recursed folders (i.e., the return will be the folders in level of folders specified in the new switch as long as jpg files are found somewhere in the recursion not necessarily in that folder level specified). Based on the fact that you state, "/parentdepth=1 would find "User1" and "User2" folders only" and User1 and User2 folders contain no jpg files themselves only in their subfolders.

Re: New search pattern switch

Posted: 20 Jul 2020 02:00
by oXYgen
That's right. It is important to note that XYplorer also has the reverse of switch /p:
/x Return all folders that don't contain any matching items (reverse of switch /p).
We actually need a complementary switch applicable for both /p and /x. It might be named /tier instead of /parentdepth to remove ambiguity. Thus /x /tier=n is the reverse of /p /tier=n. Usage example: *.jpg /p /tier=1.

I've modified my first post by adding "User3" folder to the sample tree. Searching *.jpg /x /tier=1 would find "User3" folder only.

Re: New search pattern switch

Posted: 17 Sep 2020 15:30
by admin
Well, it's pretty special, right? You are most likely the only person in the world who will use it. :biggrin:

But I like this kind of thinking, so I will add it. :cup:

Re: New search pattern switch

Posted: 19 Sep 2020 16:49
by admin
In the next beta I will give it a shot.

Re: New search pattern switch

Posted: 02 Oct 2020 09:19
by admin
Silence?

Re: New search pattern switch

Posted: 24 Nov 2020 21:38
by oXYgen
What good news :tup: I've not expected this to be added in the near future. That’s very kind of you!

Sadly, I cannot test the feature. It doesn't work in 21.20.0200. For example, if I search *.jpg /p=1 somewhere on the Desktop or Program Files, XYplorer thinks the root is C:\ and finds only C:\Users or C:\Program Files. But the actual root is deeply inside the system drive.

Re: New search pattern switch

Posted: 25 Nov 2020 15:07
by admin
Not sure what you mean. Define "root".

Re: New search pattern switch

Posted: 25 Nov 2020 17:35
by oXYgen
The "root" is the Location field on Find Files/Name & Location tab.

Suppose the following path exists: C:\1\2\3\4\5\6\7\8\9\Image.jpg. If we open C:\1\2\3 in XYplorer and try to search *.jpg /p=1 then XYplorer should find C:\1\2\3\4 folder. Currently it finds C:\1 as if the root is C:\.

What this function can be useful for? For example, multiple users share one PC:

C:\Users\Alice\
	Documents\
		Report.xlsx

C:\Users\Bob\
	Desktop\
		Database.db

Our goal is to backup profiles with *.db and apply qoutas on other profiles.

To do this we need to open C:\Users in XYplorer and search *.db /p=1. XYplorer finds C:\Users\Bob. Then we search *.db /x=1 and XYplorer finds C:\Users\Alice.

Re: New search pattern switch

Posted: 25 Nov 2020 17:45
by admin
So the root is relative to the search location. Well, since you are the only person in the universe using that feature ... or is there anybody else out there?

Re: New search pattern switch

Posted: 25 Nov 2020 17:52
by oXYgen
Yes, like /maxdepth=n switch.

Re: New search pattern switch

Posted: 25 Nov 2020 18:43
by admin
Yep, make sense. Next beta.

Re: New search pattern switch

Posted: 26 Nov 2020 17:00
by highend
* Find Files and Quick Search: Now the depth in the switches /p=[depth]
(return the parent folders of all matching items) and /x=[depth] (return
all folders that don't contain any matching items) is not relative to the
absolute root of the path anymore but relative to the search path.
Does that make sense for quicksearch() as well?