Search folders containing files with specific extension

General discussion related to "Everything".
Post Reply
rspai
Posts: 2
Joined: Tue Aug 16, 2022 3:20 pm

Search folders containing files with specific extension

Post by rspai »

I have been using Everything for sometime now but am not able to find a way to do this:
I want to list folders that contain only files with extensions .pdf or .epub
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

Re: Search folders containing files with specific extension

Post by NotNull »

Is this what you have i mind? (if not: please explain in more detail including examples):

Code: Select all

child:*.pdf | child:*.epub
horst.epp
Posts: 1456
Joined: Fri Apr 04, 2014 3:24 pm

Re: Search folders containing files with specific extension

Post by horst.epp »

That doesn't work
if he realy wants "folders that contain only files with extensions .pdf or .epub"
Stamimail
Posts: 1122
Joined: Sat Aug 31, 2013 9:05 pm

Re: Search folders containing files with specific extension

Post by Stamimail »

Search Preprocessor has conditions capabilities.
So it seems to be possible for an advanced user.
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

Re: Search folders containing files with specific extension

Post by NotNull »

Stamimail wrote: Tue Aug 16, 2022 6:35 pm Search Preprocessor has conditions capabilities.
So it seems to be possible for an advanced user.
How? The preprocessor ist 'just' that : a PRE-processor. It gives you functions that expand to a value. Before the search starts, this will be evaluated.
Meaning that it would expand to something that you could type in the search bar. What would that be in this case?


horst.epp wrote: Tue Aug 16, 2022 5:39 pm That doesn't work
if he realy wants "folders that contain only files with extensions .pdf or .epub"
Aha! that is what I missed: the "only" part. Thank you!

If @rspai wants to find folders that contain epub files and/or pdf files and nothing else (beside subfolders), regex to the rescue! :

Code: Select all

child:*.pdf | child:*.epub   !regex:child:^.*\.(?!pdf$)(?!epub$)
(Explanation of this gibberish available if needed)


But first .. let's hear what @rspai has to say ...
Stamimail
Posts: 1122
Joined: Sat Aug 31, 2013 9:05 pm

Re: Search folders containing files with specific extension

Post by Stamimail »

@NotNull Well done. (I thought that parentheses in regular expressions were only used for grouping, but I see that there are exceptions).
@rspai try also this:

Code: Select all

child:*.pdf | child:*.epub   !regex:child:^.*\.(?!pdf$)(?!epub$) childfoldercount:0
NotNull wrote: Tue Aug 16, 2022 7:17 pm How? The preprocessor ist 'just' that : a PRE-processor. It gives you functions that expand to a value. Before the search starts, this will be evaluated.
Meaning that it would expand to something that you could type in the search bar. What would that be in this case?
If so, would POST-processor tasks be possible using CMD (es.exe) and pipes?
rspai
Posts: 2
Joined: Tue Aug 16, 2022 3:20 pm

Re: Search folders containing files with specific extension

Post by rspai »

Thanks a ton, everyone, for all the inputs.

The very first response by @NotNull was a pointer to what I was looking for. The last two responses by @NotNull and @Stamimail have given me the results I was looking for. (I need to do a sample verification.)

Also, eagerly looking forward to @NotNull offer of "explanation of this gibberish available if needed". Thanks, once again.
klark1kent
Posts: 21
Joined: Thu Aug 11, 2022 1:26 am

Re: Search folders containing files with specific extension

Post by klark1kent »

Old topic, and no follow up needed, but just passing it along. These examples all worked flawlessly me for the first folder, but if the folder contained subfolders, and I went into those subfolders, there were a couple instances where files with other formats were included (in my case .icc and .docx). The first folder though always contained just PDF
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

Re: Search folders containing files with specific extension

Post by NotNull »

rspai wrote: Wed Aug 17, 2022 1:10 am Also, eagerly looking forward to @NotNull offer of "explanation of this gibberish available if needed". Thanks, once again.
This one slipped through the cracks, so a *little* late:

Code: Select all

!regex:child:^.*\.(?!pdf$)(?!epub$)
regex: = Go in Regular Expression mode
^ = Start of the filename
^.*\. = Read as many characters of the filename as you can, up until teh *last* dot (.) of the filename (meaning we are at the start of the extension of the filename)

! = NOT
$ = End of the filename
(?!pdf$) = look ahead to the end of the filename ( that is the extnsion). It may not be equal to pdf
(?!epub$) = Same for epub

So ^.*\.(?!pdf$)(?!epub$) finds filenames that do NOT have pdf or epub extensions.
The ! (NOT) before regex: makes Everything exclude all folders that do include non-pdf or non-epub files.


klark1kent wrote: Fri Jan 19, 2024 5:59 pm no follow up needed
Sorry, couldn't resist :D ...

The following search query will find all folders that do have only epub or pdf below them, includinbg subfolders.
So any folder that is listed is "guaranteed" to have only pdf and epub files in them. No other type of files.
Empty folders will not be listed.

Code: Select all

descendant-file:*.pdf;*.epub  !regex:descendant-file:^.*\.(?!pdf$)(?!epub$)
klark1kent
Posts: 21
Joined: Thu Aug 11, 2022 1:26 am

Re: Search folders containing files with specific extension

Post by klark1kent »

Yep that last string did the trick - and I get it, the same way you couldn't help but respond is the exact reason I couldn't help but provide the feedback.
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

Re: Search folders containing files with specific extension

Post by NotNull »

:D :thumbsup:

Please keep posting feedback!
Post Reply