How do I set the default search for Finder to filenames which INCLUDE the search term (rather than just begin with it)? Yosemite
I'm using Yosemite (OS X 10.10.1). If I search for the term "foo" and want a list of all files that include that term, I get foo.doc and bar.foo.doc and foodstuffs.xlsx and even The Foo History. But it does not include snafoos.docx and AllTheFooReports.xlsx. How can I change it to the (obvious!?!) behaviour of returning all results which include the search term?
I'd like to be able to do this from within Finder, not just in terminal.
The Finder searches for word prefixes.
If you save your search as a Smart Folder and then inspect that using a text editor (e.g. TextMate) you will see the raw Spotlight query:
((kMDItemDisplayName = "foo*"cdw))
The "w" modifier tells Spotlight to search for words. The "*" wildcard at the end of the search string makes Spotlight search for word prefixes. It will match names that contain a word beginning with "foo".
That matches all of your examples but one. "foo" comes at the start of the file name, after a space or punctuation or is capitalized. The exception is "snafoos" where "foo" is just a sequence of letters in the middle of the word.
You could change the query in the smart folder to:
((kMDItemDisplayName = "*foo*"cd))
Or click the "+" button below the search field in Finder and add a "name" "contains" "foo" criterion.
Or use mdfind in Terminal:
mdfind -onlyin . '((kMDItemDisplayName = "*foo*"cd))'
Or use HoudahSpot (of which I am the developer) to get more control over your search.
If you are stuck you could use a find command in a terminal window.
Open a terminal window and type :$ find . -iname \*foo\*
Here's an example using the files you mentioned in your question.
mgagnon-mbp:tmp mgagnon$ ls
AllTheFooReports.xlsx bar.foo.doc foo.doc foodstuffs.xlsx snafoos.docx
mgagnon-mbp:tmp mgagnon$ find . -iname \*foo\*
./AllTheFooReports.xlsx
./bar.foo.doc
./foo.doc
./foodstuffs.xlsx
./snafoos.docx
If you're not familiar with the terminal this is a fun way to learn! :) The easiest way to open a terminal windows is using a spotlight search (command-spacebar) and search for terminal.
Hope this helps.