Windows Syntax & Search


  1. Posts : 30
    Windows 10 Home
       #1

    Windows Syntax & Search


    Hi!
    .
    I want to search for strings that occur within the contents of text files.
    .
    I am definitely missing something with respect to Windows' search syntax or Windows in general...sorry!
    .
    To avoid the complexity of my specific issue, I created the following test scenario.
    .
    1) I created a file called test.txt on my Desktop
    .
    2) I entered the string "abc123abc" in test.txt
    .
    3) I double checked that test.txt is indexed...it IS
    ....a) I deleted and rebuilt my index database
    ....b) I double checked that test.txt is indexed again...it IS again
    .
    4) I attempted to search, unsuccessfully, for test.txt
    ....a) My search strings are
    ........i) not "test"
    ........ii) "abc"
    ........iii) "123"
    ........iv) "*abc*"
    ........v) "*123*"
    ........vi) "?abc?"
    ........vii) "?123?"
    .
    I really do not understand what I am missing.
    .
    Please help!
    .
    Thanks,
    Mark
    .
    PS: Those dots everywhere are to counter this forum's automatic white space edit.
    Last edited by razam; 11 Feb 2018 at 13:18. Reason: Automatic White Space Edit F'ed My Post
      My Computer


  2. Posts : 17,661
    Windows 10 Pro
       #2

    Search for a file containing a specific string in file contents:

    contents:string

    Search for a file with two specific strings in file contents:

    contents:string1 AND contents:string2

    Search for a file with at least one of three specific strings in file contents:

    contents:string1 OR contents:string2 OR contents:string3

    Search for a file with one of two specific strings in file contents, excluding files which also have a spefic string:

    contents:string1 OR contents:string2 NOT contents:string3

    Note that logical operators AND, OR, NOT must be given in all uppercase.

    Kari
      My Computer


  3. Posts : 30
    Windows 10 Home
    Thread Starter
       #3

    Thank you for your reply Kari.
    .
    Please help me understand another detail.
    .
    When I enter into the search text box, the following strings,
    ...."contents:abc"
    ........I find test.txt
    ...."contents:123"
    ........I do not find test.txt
    ...."contents:*abc*"
    ........I find test.txt
    ...."contents:*123*"
    ........I do not find test.txt
    ...."contents:?abc?"
    ........I find test.txt
    ...."contents:?123?"
    ........I do not find test.txt
    .
    Why do I not find test.txt when searching for "contents:123", "contents:*123*", and "contents:?123?" while I do find test.txt when searching for "contents:abc", "contents:*abc*", and "contents:?abc?" ?
    .
    Thanks,
    Mark
    Last edited by razam; 11 Feb 2018 at 14:05. Reason: Why does this forum mess with my white space?
      My Computer


  4. Posts : 17,661
    Windows 10 Pro
       #4

    Add double tilde (~~) to search a partial string within a string:

    contents:~~123

    Without two tildes, the partial string you are searching for must be at the beginning of the string. Double tilde tells it can be located within a longer string.

    Kari
      My Computer


  5. Posts : 30
    Windows 10 Home
    Thread Starter
       #5

    With respect, I still do not understand because my searches for both

    contents:~~abc

    and

    contents:~~123

    fail to find test.txt.

    Is there documentation regarding Windows syntax that you can refer me too?

    Thanks,
    Mark
      My Computer


  6. Posts : 17,661
    Windows 10 Pro
       #6
      My Computer


  7. Posts : 43,010
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #7

    Hi, it seems the difficulty is that you must specify text from the start of the string.

    The question is discussed here:
    File Explorer how to search content using wildcards


    Neither * nor ? are recognised as wild card characters in content search- * seems to be ignored.
    (They are valid for filename search though).

    What works (for me!)
    abc*
    abc
    abc123

    Note that
    *abc finds the file, which might suggest
    *3abc would, but it doesn't.

    What doesn’t work:
    *123abc
    ???123*
    ???123???
    123abc
    abc*abc

    Advanced Query Syntax gives a lot of information, but is old and not complete.
    Even 'How to Geek' only gives a simple example of text content search
    Learning Windows Search: Use Boolean, Dates, and Wildcards to Give Your Searches a Boost

    3rd party tools are just simpler.. even if they don't index content like this one:
    Windows Syntax & Search-1.jpg
    Here I started from 'Everywhere' (both disks), specified txt documents containing 123abc

    The result was fairly quick.
      My Computers


  8. Posts : 30
    Windows 10 Home
    Thread Starter
       #8

    Thanks for your help. I decided to use Notepad++ and/or Grep for Windows.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 17:54.
Find Us




Windows 10 Forums