34

I'm trying to find files in Windows 7 that have a parenthesis in the file name.

However, when I type ( or *(* or "(" or *"("* I get either nothing or every file.

Microsoft's "advanced query syntax" reference for desktop search mentions nothing about this.

What gives?

3

8 Answers 8

38

Use following syntax: ~="(".

~= is an escape character and then you can put a special character like (, &, ? etc. in double quotes.

4
  • 1
    But how can I search for files containing the ~ character (e.g. word lock files '~$xyz.doc' ? Commented Jul 25, 2014 at 16:17
  • 5
    Like this: ~="~$" Commented Apr 12, 2016 at 8:16
  • 2
    I had to omit the quotation marks for this to work with a period.
    – sirdank
    Commented May 19, 2016 at 12:15
  • Worked for a single quote without quotes of any kind
    – PRMan
    Commented Dec 11, 2021 at 18:27
6

This WORKED PERFECTLY to find 'numbered'/duplicate FILES:

   name:~"*(1)*"

alternately, to find numbered / duplicate FOLDERS use:

   kind:folder name:~"*(1)*"


~="(" as suggested in another answer didn't work for me in Windows 10

In my case, I needed to find FILE COPIES / "numbered files", i.e. find files with "(1)" appended to the end of the filename, e.g. files that are created when/by:

  1. you drag / explorer copy files into a folder, where files with the same filenames already exist.
  2. cloud syncing storage software, such as OneDrive, GoogleDrive, or DropBox encounters syncing issues or conflicts and creates 2 copies of a file, naming one with an appended number "duplicate file", "duplicate file (1)", "duplicate file (2)", etc...
5
  • This doesn't answer the question (at least not directly). Commented Sep 21, 2017 at 6:26
  • @MátéJuhász did u downvote me really? really? does using my suggestion without the number "1" not work for you? thanks Commented Sep 21, 2017 at 21:20
  • This actually worked for me. Using filename:~"*TEXT*"where TEXT is the exact input with special characters. The top answer did not work, I could not make it work with or without quotes, with or without asterisks.
    – Liggliluff
    Commented May 24, 2018 at 11:11
  • Care to +1 it? 😉 Commented May 24, 2018 at 11:59
  • 1
    At last a good answer that could filter out filenames with (1) ONLY, without including arbitrary names with 1. Thank you!
    – Noam Manos
    Commented Apr 29, 2020 at 10:50
6

Let's Help!

For any Windows Search issues my recommendation is two things:

  1. Read the AQS (Advanced Query Syntax) documentation, so you know what all the special characters do.
  2. Know that Windows Search will convert your query into precise AQS and unless you are specific in your queries, Windows will guess what AQS you actually meant. The results can be surprising!

First, some of basics on AQS

By default, string file properties (Filename, author, etc.) search with COP_WORD_STARTSWITH $<, so any word (separated by spaces , - _ () [] and more) that starts with your search term. Other non-string properties (Dates, etc.) search with COP_EQUAL =, or exact matches by default (No wild cards, * and ? are literal).

Second, if you are searching in any indexed location, then all non-indexed locations in your query will not be shown.

Third, Click on the Address Bar to see what AQS Windows Search actually searched with. You can ignore location crumbs and display-name: It will be percent encoded, so decode on a site like https://www.url-encode-decode.com/

Fourth, undocumented, * and ? behave unpredicatbly in AQS unless they are in a ~ COP_DOSWILDCARDS query (meaning the non-word starts with, and wild cards * or ? are interpreted). Windows search will usually convert searches to a ~ query. For example, it seems wild cards ** and ? with alphanumeric characters search string properties with ~, but ** without alphanumerics searches nothing. Also single * in non ~ queries are treated as a wildcard with COP_WORD_STARTSWITH $<.

Let's Analyze your queries

  1. ( AQS search-ms:displayname=Search Results in Users&crumb=&crumb=location:C:\Users Simplified crumb=

    Well, unquoted (is a grouping operator for when you use AND or OR, you grouped nothing, so Windows thinks you meant group nothing search everything.

  2. *(* AQS crumb=

    Most windows searches that starts with * windows tries to convert to a crumb=~~query_term (a contains search). * is treated as normal in a contains query. Anyways, in this case you wild card a group of nothing, so Windows searches for all groups of nothing (or everything!)

  3. "(" AQS crumb=System.Generic.String:"("

    Quotes search for exact phrases (the entire word or property should match) and are literal characters except for *, ? and "" become ". This searches for words that start with (, but since words are not ( it only searches for properties that are just (

  4. *"("* AQS crumb=Rating:(>=1 <13) OR System.Generic.String:** System.Generic.String:"("* This one is crazy, but Windows Search tries to convert prefixed * followed by certain special characters as star ratings. 1-13 is 1 star. Also note from my testing, ** without any alphanumeric characters before or after it searches for nothing instead of a wild card and is unpredictable.

    This full query means

    (1 star rating OR Word that starts with nothing) AND properties that are just (. * won't match any other characters because the whole property has to be (.

    Simplified it means, 1 star files called (

    ** in the query actually showed a non-one star ( file for me, but when changing the ** to *** and back to ** it gave the expected no results (** is unpredictable)

The other answers

  1. ~="(" AQS crumb=System.Generic.String:~="("

    This didn't work, windows seems to not find anything if the amount of searching is too intensive. filename:~="(" does work. Essentially find a filename that contains just a ( somewhere

  2. "*(*" AQS crumb=filename:~~"*(*" OR System.Generic.String:"*(*" This worked. Filename contains *(* with wild cards OR any property word that starts with wild cards and has a (. Note, both ~= and ~~ mean contains.

5

Got it!

Just had to type this into the search box:

"*(*"
2
  • This worked for you with Windows 7? For me it returns all files (same with "*$*", since I was actually looking for dollar signs in filenames.) What did work for me was ~="(" (with quotes for parentheses) and ~=$ (no quotes for dollar sign).
    – ashleedawg
    Commented Jul 26, 2018 at 6:54
  • 1
    That's my favorite answer, works great o windows 10!. However, if you know the full name of file that has special characters, you can just search for 'FULL-NAME' instead of ' "*FULL-NAME" . I mean, you can drop off the quotation marks "" and drop off the last star *'
    – Dudi
    Commented May 9, 2020 at 18:00
0

Use this in the search box:

~"*(2)*"
2
  • 4
    Can you explain?
    – bertieb
    Commented Mar 13, 2017 at 7:54
  • @bertieb According to learn.microsoft.com/en-us/windows/win32/search/… , i think the ~ should make * and ? special. But, tested in Windows 10, "*(2)*" also has that. In practice, the ~ seems to limit the search to filenames, equivalent to name:~"*(2)*". (Whereas name:"*(2)*" also interprets *, but ignores ( and ). 🤷‍♂️!…) Commented Jun 18 at 22:44
0

Use this expression to search with filenames,

filename: "*(1)*"
0

~"* (?).*" for duplicates not exceeding (9), just add another ? for 2 digits. But be careful using * instead of ?. It broadens the search considerably and the results may no longer be desireable.

0

"*(*" and
name:~~"(" worked for me in Windows 10.
name:~~"(" highlights the ( in the search results.

name: is an alias for filename:.
~~           is an alias for ~=. They mean contains.[source 1]

These did not work in Windows 10:

  • ~"("
  • ~="("
  • ~="*(*"
  • name:"*(*"

This covers all previous answers.

("*(*" seems to be equivalent to name:~"*(*".)


[source 1] https://learn.microsoft.com/en-us/windows/win32/search/-search-3x-advancedquerysyntax#query-operators:~:text=COP_VALUE_CONTAINS

You must log in to answer this question.

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