Search for X number of characters in file name

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
Mufasa
Posts: 7
Joined: Wed Dec 30, 2020 4:39 pm

Search for X number of characters in file name

Post by Mufasa »

Hey everyone,
I cant figure out searching for a file name that has a fixed number of characters after a unique word, I'm trying to search for "Photo_AZ123456789" where the AZ1-9 is different for each file but same length.
Appreciate any suggestions.
therube
Posts: 4955
Joined: Thu Sep 03, 2009 6:48 pm

Re: Search for X number of characters in file name

Post by therube »

I'm not sure where "simple" wildcards stand, so a regex: that should work:
regex:^photo_........$

Will find words that starts (^) with the word "photo", are followed by an underscore (_), followed by (in my example) any nine characters (.), followed by nothing further ($).

Adjust as needed.

As written, it will find, "photo_finder.zip".
If you remove the starts with (^), it will find, "awesome_photo_finder.zip".
Adjust the number of dots (.) to fit your needs. ...
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Search for X number of characters in file name

Post by NotNull »

You can use a ? wildcard to specify one single character:
photo_???????????.jpg
(11 question marks; 2 for the letters and 9 for the numbers).


More exact, but more difficult too, would be using regular expressions:
regex:"^photo_[a-z]{2}[0-9]{9}\.jpg$"


Subtitled: Search for files that:
- start with photo_
- followed by two characters in the range a-z
- followed by nine numbers (0-9)
- followed by a dot ( . )
- and ends with jpg

regular expression searches in Everything are case insensitive, so it will find az as well as AZ or aZ

@therube: sorry, missed your reply ...
Mufasa
Posts: 7
Joined: Wed Dec 30, 2020 4:39 pm

Re: Search for X number of characters in file name

Post by Mufasa »

Perfect, thanks to @therube as well.
for future reference, how can I use both expressions [a-z][0-9]{3}$ to search for files when numbers and letters aren't in order? like AZ8, A8Z, 8AZ?

NotNull wrote: Tue Jun 01, 2021 3:17 pm You can use a ? wildcard to specify one single character:
photo_???????????.jpg
(11 question marks; 2 for the letters and 9 for the numbers).


More exact, but more difficult too, would be using regular expressions:
regex:"^photo_[a-z]{2}[0-9]{9}\.jpg$"


Subtitled: Search for files that:
- start with photo_
- followed by two characters in the range a-z
- followed by nine numbers (0-9)
- followed by a dot ( . )
- and ends with jpg

regular expression searches in Everything are case insensitive, so it will find az as well as AZ or aZ

@therube: sorry, missed your reply ...
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Search for X number of characters in file name

Post by NotNull »

Mufasa wrote: Tue Jun 01, 2021 7:47 pm for future reference, how can I use both expressions [a-z][0-9]{3}$ to search for files when numbers and letters aren't in order? like AZ8, A8Z, 8AZ?
This should do it (untested):
[a-z0-9]{3}

(made i a bit larger as there was hardly any difference visible between [] and {}. At least on my system)
Post Reply