New search pattern switch

Features wanted...
oXYgen
Posts: 43
Joined: 26 May 2014 05:57

New search pattern switch

Post 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.
Last edited by oXYgen on 27 Nov 2020 11:29, edited 3 times in total.

klownboy
Posts: 4338
Joined: 28 Feb 2012 19:27
Location: Windows 11, 24H2 Build 26100.4351 at 100% 2560x1440

Re: New search pattern switch

Post by klownboy »

I haven't tried it, but have you tried combining the /p switch with the /maxdepth=n switch?

oXYgen
Posts: 43
Joined: 26 May 2014 05:57

Re: New search pattern switch

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

klownboy
Posts: 4338
Joined: 28 Feb 2012 19:27
Location: Windows 11, 24H2 Build 26100.4351 at 100% 2560x1440

Re: New search pattern switch

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

oXYgen
Posts: 43
Joined: 26 May 2014 05:57

Re: New search pattern switch

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

admin
Site Admin
Posts: 63607
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: New search pattern switch

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

admin
Site Admin
Posts: 63607
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: New search pattern switch

Post by admin »

In the next beta I will give it a shot.

admin
Site Admin
Posts: 63607
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: New search pattern switch

Post by admin »

Silence?

oXYgen
Posts: 43
Joined: 26 May 2014 05:57

Re: New search pattern switch

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

admin
Site Admin
Posts: 63607
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: New search pattern switch

Post by admin »

Not sure what you mean. Define "root".

oXYgen
Posts: 43
Joined: 26 May 2014 05:57

Re: New search pattern switch

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

admin
Site Admin
Posts: 63607
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: New search pattern switch

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

oXYgen
Posts: 43
Joined: 26 May 2014 05:57

Re: New search pattern switch

Post by oXYgen »

Yes, like /maxdepth=n switch.

admin
Site Admin
Posts: 63607
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: New search pattern switch

Post by admin »

Yep, make sense. Next beta.

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

Re: New search pattern switch

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

Post Reply