4

I am looking for the pattern to use the windows explorer search bar to find all files (Not folders) in the current directory and all sub directories that start with the pattern 1- for example the file 1-file.txt should be found but the file 1file.txt not

I tried several syntax approaches that I know from GNU Grep or SED.

But the windows search bar always returns non sense, like files that just contain the number 1 somewhere in the filename.

4 Answers 4

2

Are you open to using 3rd party tools? If you are, Everything by voidtools.com is pretty good and has very fast search capability. The tool indexes your whole computer and show you result as you typed.

1
  • works well out of the box fast index, understandable which data will be scanned. Does not try to connect to the internet (a lot of freeware does) Commented Aug 5, 2021 at 12:45
2

In some delightfully hard-to-find MS Documentation, there's information regarding several string-specific query operators. One of them is COP_VALUE_STARTSWITH:

Operator: COP_VALUE_STARTSWITH
Symbol: ~<
Example: System.FileName:~<"C++ Primer"
Description: Finds items where the file name begins with the characters "C++ Primer".

So, to find only files that begin with "1-", use:

FileName:~<1-

Other operators include:

  • COP_VALUE_ENDSWITH: ~>
  • COP_VALUE_CONTAINS: ~= or ~~
  • COP_VALUE_NOTCONTAINS: ~!
  • COP_DOSWILDCARDS: ~

VALUE_CONTAINS overcomes the default word-based (as opposed to character-based) nature of Windows Indexing. Using name:~~cess:

enter image description here

DOSWILDCARDS allows the wildcard characters ? and * to be used in quoted strings. And characters that are part of seach syntax, such as (, ), [, and ], must be in quotes to interpreted as search characters. So to find files that have parenthetical indices at the end of the filename, use FileName:~"*(*).*"

enter image description here

Again, the complete list is here:

Using Advanced Query Syntax Programmatically - Query Operators

0

See http://hs.windows.microsoft.com/hhweb/content/m-en-us/p-6.2/id-8d6963c6-f737-4009-a061-22cbb976bdc3/

name:"1-*.*"

But the options on the search tab affect what will happen.

1
  • Doesn't work unfortunately, finds lots of files and folders that just contain "1" in the name somewhere
    – David.P
    Commented Jun 7, 2022 at 14:45
0

You can also utilize the power of the Linux / GNU Commands, by installing "Git for Windows" from https://www.git-scm.com/download/win ( accept its default recommendations, while setup ) and then :

  1. Open File Manager & navigate to your search Folder & Right Click on an empty space, to choose "Open Git Bash here"

  2. Copy the below mentioned command and paste it in the "MINGW..:Your_Search_Folder_Path" window and press Enter / Return key to run it.

find . -type f -name "1-*"

If the results shown by the above command are satisfactory, then I usually follow it up, with the below command, which changes the "Date Modified" value, to the current time, thereby making those files, raise to the top, on the file manager ( when sorted by "Date Modified" descending ) :

find . -type f -name "1-*" -exec touch -m {} \; 

Screenshots Below :

Git_Bash_Find_Command

Many useful variations of the find and grep commands, for searching files, are given in the links below :

a. https://sysaix.com/43-practical-examples-of-linux-find-command

b. https://www.serverwala.com/blog/how-to-use-grep-command-in-linux-unix-with-examples/

Hope this helps someone.

3
  • If you are installing Git just for this purpose, then better go with Cygwin.
    – ysap
    Commented Jun 8 at 15:07
  • Hi @ysap, Does Cygwin offer an easy "Open Terminal Here" on the File Manager's Context Menu, so that we don't navigate inside it, with the cd command ? Commented Jun 8 at 18:12
  • I am not aware of that option, so I can't comment on that. maybe worth a new question on this issue.
    – ysap
    Commented Jun 10 at 18:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .