Using Advanced Query Syntax To Find Files in Windows 7

Files are tricky things. They are very good at hiding within the file system. Well that’s how it seems to me. If I’m honest, the file does hide really, I just forget or confuse the one I’m looking for with another one. Usually the name, so I end up starting at the top of a folder structure knowing the files was a .docx or .xlsx file. Genius! Fortunately Advance Query Syntax helps me out.

You can use AQS from the search box on the Start menu or from within Explorer, the syntax is the same. AQS is part of Windows Desktop Search and is part of Windows 7 by default. I’ve included a link to version 4.0 below for those not on Windows 7.

What AQS allows you to do is use some of the 300+ attributes that files can have to tag them. So for example, recently I changed managers and I know my previous manager sent me a document about year end stuff. I know I saved it somewhere in My Documents, but where? Using AQS I can open My Documents and type

authors:cslotta

into the search box. Now I get a list of all the documents with the Authors property set to my managers name. The AQS syntax is made up of

attribute:value

combination. As I mentioned there are hundreds of attributes to choose from. The trick with attributes is understanding how to enter them. For example

Modified:12/08/10

DateModified:12/08/10

Date Modified:12/08/10

are all equal. The rule of thumb is to remove the space from attributes, as in the second one above, or like “Date last printed” becomes “Datelastprinted”.

The value part of the syntax is very flexible and allows for a number of operators. Say, for example, you want to see how many files you have in a folder structure over 250mb, to find those enter

size:>250mb

The are some predefined sizes you can use, they are not as granular as the example above.

Empty: Files that are 0kb in size.
Tiny: Files 0kb to 10kb in size.
Small: Files 10kb to 100kb
Medium: Files 100kb to 1mb
Large: Files 1mb to 16mb
Huge: File 16mb to 128mb
Gigantic: File bigger than 128mb

Using size:Gigantic is similar to the example above, but will return more results – if there are files in the 128mb to 250mb range in the folder.

You can take this example further and search for files within a size range. The next two examples are equivalent.

size:>=10mb <=20mb

size:10mb..20mb

The “..” signifies a range of values, for example

datemodified:1/7/2010..1/8/2010

specifies a date range. Depending on where you are in the world read it as all files modified in July or all files modified between January 7th and 8th. Either way, its a date range. You can also search for two specific dates, for example on my machine with the UK date format

datemodified:(1/7/2010 OR 1/8/2010)

Searches for a file modified on either July 1st or August 1st. You can use the AND operator too. The next examples are interesting and taken from the documentation.

authors: (Charlie AND Herb)

authors: Charlie AND Herb

They look similar, but return completely different results. The first example looks for files that are authored both by Charlie and Herb, the second example looks only for Charlie as the author, then looks for Herb in the file name or any other file property. So a Resume document called “Herb Resume.docx” authored solely by Charlie would only appear with the second example.

As a note, when using AND, OR or NOT, they must appear in uppercase in the query.

Let’s look at some other operators now. if you are diligent in maintaining file properties, a useful search maybe to find files that do not have the properties you expect populated.

authors:[]

This search returns all the files who's authors property is empty. Another nice option is how search recognises certain keyword values. Such as these values related to dates.

Relative dates: Today, tomorrow, yesterday

Multi-word relative dates: week, next month, last week, past month, or coming year. The values can also be entered contracted, as follows: thisweek, nextmonth, lastweek, pastmonth, comingyear.

Days: Sunday, Monday ... Saturday

Months: January, February ... December

Try these examples:-

datemodified:yesterday

datemodified:January
 
Finally, before I let you go play with this, just a reminder that you can use the * and ? operators. For example, in my case sometimes I put my full name into the author field, other times Word uses the alias I entered. To find both variations:-

 authors:alan*

The area I’ve not covered here is the natural language query, I’ll cover that another time.

Related Links

Install Windows Search 4.0

Windows Search Advanced Query Syntax

Related books

Al these publications cover the material in this post.

Windows 7: The Definitive Guide, First EditionMicrosoft Windows 7 UnleashedMicrosoft Windows 7 In Depth

Comments

  • Anonymous
    August 13, 2010
    Is there any way to use this feature to search for one specific file on many servers using something like Powershell?

  • Anonymous
    August 16, 2010
    Hi Carlos, You can access Windows Search programatically. The samples us VB Script, but that could be converted to PowerShell I'm sure. It's use .Net libraries, so initially I don't see why not. The code in the example also mentions how to access Search running on remote machines. Search has to be installed on those machines, the "Install" link in my post covers the supported OS's. Alan This is a VB Script sample using ADO.NET msdn.microsoft.com/.../dd940332(v=VS.85).aspx Windows Search Developer Guide msdn.microsoft.com/.../ff628790(v=VS.85).aspx

  • Anonymous
    August 16, 2010
    Excellent information Alan.

  • Anonymous
    September 29, 2010
    Do you know if you can do something like find all files that were modified in the last 10 minutes ?

  • Anonymous
    October 18, 2010
    Excellent tutorial . Found a similar one there : www.computing-tips.net/Find_file_Windows_7 @Dario Strbenac  - Not sure if it is possible in Windows 7 - but Windows XP is YES.

  • Anonymous
    February 23, 2011
    Definitely the advance tech query has helped a lot of people with their missing files, not missing files but finding the files, whose names have been forgotten by the user himself. The use of these syntax may not be so common among all the computer users but this is the definite way to look for your miss placed files. I have been doing this since more than a year and this really works. Cheers. <a href="http://www.marketingtechblog.com">Internet marketing blog</a>

  • Anonymous
    August 25, 2011
    So... where does Microsoft document the Windows 7 AQS? I see a number of pages for Window Search 4.0 (specifically referencing VISTA), but I have found not a single detailed documentation page for Windows 7 Search.

  • Anonymous
    August 25, 2011
    @Coran The Iowan, That is right, the AQS is related to Search 4.0 rather than Windows 7. The same syntax is used in Vista and XP. As long as the documentation is related to Search 4.0 then it works on Windows 7. MSDN has some documentation on AQS and I listed some script resources in a previous reply. Advanced Query Syntax msdn.microsoft.com/.../bb266512.aspx Alan

  • Anonymous
    November 26, 2012
    Evidently all the questions posted here are completely ignored.

  • Anonymous
    March 25, 2014
    Totally, totally useless. search for string does not work at all. Microsoft, if its broke, FIX IT!! its broke.

  • Anonymous
    April 08, 2014
    Thanks very much for offering excellent information here... I like your website. Thanks very much and keep publishing..... I'm looking forward to your new material.
    http://www.techtrendsit.com/application-development/

  • Anonymous
    March 09, 2015
    Very interesting tutorial about AQS. I just forget all those queries all the time. So I am using a Windows Search alternative which replaces my lack of learning with simple search queries. To do this I am using Lookeen a fast and easy to use desktop and enterprise search solution.
    http://www.lookeen.com

  • Anonymous
    October 14, 2015
    I don't want to come across as a "hater" but in my opinion anyone trying to inform/teach people about AQS (and that includes people writing in the comments as well) should at least add the caveat that AQS is "rife with bugs".
    And if You try to use it and it doesn't yield the results You were expecting chances(risks) are rather great that You have done everything correctly but You have only been unlucky enough to have Your effort trounced by one of the innumerable""broken features"" in AQS.
    So before You put to much effort into trying to "bug fix" Your AQS, make a search and see if You can find someone else documenting their success or failure with the feature You are trying to use.
    Because more often than not You will find that the feature is broken in some way or other.
    I.e. often it's not Your AQS that is at fault but rather that AQS doesn't work as described/"""documented""" by M.S. if it works at all.
    Best regards.... and luck...

  • Anonymous
    January 03, 2016
    KrojamSoft FilesSearch Tool helped me in this case.

  • Anonymous
    January 10, 2016
    have you tried KrojamSoft FilesSearch? it can help