regex to find files with sequential names

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
Meroveus
Posts: 2
Joined: Thu Jul 22, 2021 2:46 pm

regex to find files with sequential names

Post by Meroveus »

I have a huge number of files with names like:
base.pdf
base(1).pdf
base(2).pdf

I thought I would try a regex to show all file of this pattern
part of it is easy:
regex: \(\d+\)\..+$

This leaves out the ones with out the sequence numbers -- how do I include them?

Thanks!
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: regex to find files with sequential names

Post by void »

You may need to add more constraints, as the following will match almost everything:

regex:(\(\d+\))?\.

( and ) = grouping
? = match previous element zero or one times.

Example:

regex:base(\(\d+\))?\.pdf




The following search with Everything 1.5 will show files containing ( digits+ ) where a file without ( digits+ ) exists.

For example, show base(1).pdf when base.pdf exists:
regex:^(.*)\(\d+\)(\..*)$ fileexists:\1\2

and the inverse, show base.pdf where a base(1).pdf exists:

regex:^(.*)(\.[^.]*)$ fileexists:\1(1)\2



Combining these might get you close to what you want:
regex:\(\d+\)\..+$ | < regex:^(.*)(\.[^.]*)$ fileexists:\1(1)\2 >

--This will list:
base.pdf (when base(1).pdf exists)
base(1).pdf
base(2).pdf

Everything syntax:
| = OR
< and > = Grouping
Post Reply