How To Easily Search For Files Using AND, OR and NOT

When you search for files you can use boolean operators like AND, OR and NOT. The hard way is to use the convoluted search interface. But you can also just type out your search request to get it done quickly and simply.

Comments: 9 Responses to “How To Easily Search For Files Using AND, OR and NOT”

    Neil
    3 months ago

    Good tip.

    This doesn’t seem to work in the search field in Photos.

    Searching for two or more “Family_Bob Family_Sue” keywords uses ‘and’ operation. Doesn’t seem to be an ‘or’ operation available to get two groups of photos combined.

    Smart albums are clumsy if you just want something temporary.

    Is there a better way?

    3 months ago

    Neil: This video is for searching in the Finder, not in Photos. Using a Smart Album would be the way to go in Photos.

    Chris in CT
    3 months ago

    Very helpful!
    Where would one find a list/dictionary of search terms beyond Name, Kind, Created, etc.?

    3 months ago

    Chris: I don't know of any comprehensive list, but Apple shows some here: https://support.apple.com/guide/mac-help/narrow-search-results-mh15155/mac
    You can also sometimes get more by creating a Smart Folder, then opening that Smart Folder's file in a text editor to examine how the search terms are represented in the text.

    Jasper
    3 months ago

    Hi Gary,
    1. When I open a SavedSearch, I get a long xml file, which includes, e.g., 'kMDItemUserTags = "Flock 🐑"cd) Query. What would one do with this? It's not the same format as the Finder search tokens...although pasting it in retrieves the SavedSearch file.

    2. And I'm I right in thinking that there's no Finder token to restrict the search to a specific file? Something like 'folder:Documents'

    TIA, Jasper

    3 months ago

    You use it in the same way you use the tokens in my examples. So instead of name:myname you would use kMDItemUserTags:mytag. It is just the "kMDItemUserTags" you are looking for.
    You don't include the folder (path) in the search part, you do that by starting in that folder. See at the top in my example it shows "This Mac" and "Documents" and Documents is chosen because that is where I was when I started the search.

    Bernard
    2 months ago

    When I type the search string “name:test” into the search field the system internally uses the matches option. How can I change it to the contains option?
    In the “savedSearch” XMLs it looks the following:
    1) matches: “(kMDItemDisplayName = "test*"cdw)"
    2) contains: “(kMDItemDisplayName = "*test*”cd)”
    Both options “kMDItemDisplayName:test*" or “...Name:*test*” don’t work in the Finder search field. Only without asterisks I get results but then I won't find compound words like “retest”.

    2 months ago

    Use command+option+f and then the fields and menus below to do complex searches like that instead

    Bernard
    2 months ago

    Sure, but that's very cumbersome to select the same items from two drop-down lists over and over again when I principally want to use the contains option. I wonder why the option in the standard search dialog was renamed to “Name Contains” while “matches” is still used in the background? In older OS X versions the option was correctly called “Name matches”.
    https://discussions.apple.com/content/attachment/c5f27137-a5d9-4f2d-947b-db07a6de2ea6

Leave a New Comment Related to "How To Easily Search For Files Using AND, OR and NOT"

:
:
:
0/500 (500 character limit -- please state your comment succinctly and do not try to get around this limit by posting two comments)