You can search for files using the Raw Query function in the Finder. This gives you the ability to use wildcards to search for files with specific file names. You can also use other file attributes and combine them for even more complex searches. Raw Query is also very fast and can search your entire drive in seconds.
As an example here I've got some text files that I have created and put in a Samples folder in my Documents folder. So say I want to find one of these. Of course I can just use the basic search functionality here of the Search box at the top and type in the name. And I can even say I want it to be the Name Matching, not Contents. And it will find this file. I can specify that I want it in the current folder instead of the entire Mac. That all works really well.
But say I wanted to do something a little more complex. Like I wanted to find all files that ended with something or began with something or had certain characters in it. I want to basically use Wildcards that you might do in the more advanced system for searching for things.
But you can do that with the regular search if you know how.
So let's do something a little more complex. Say I wanted to find the file that ends with the letter Y. There is five out of seven here. So what I can do is I can start a search. I hit the spacebar here to start a search. I'm going to just search within that folder. I'm going to add search criteria here and I'm going to say, I can say the name ends with Y. You can see it works.
But what if I wanted to do something more even complex. What if I wanted something like the ones that have two p's in them or two e's in them. Well, I can't really do that with this very easily. I can do Contains and that will work. But I can't get even more complex than that. So I'm going to switch to, instead of searching by name, to search by Other and in this huge list of things you can search for, I can jump down to Raw Query. I'm going to search by Raw Query which I'm going to check off here so it appears now in the menu. So now it is easy to add.
With Raw Query I can search for things based on very specific things in the name. I have to use this special attribute. You have to list attributes. So kMD item display name then equals and I can do something like wildcard ppy, anything that ends in ppy or anything that has pp in the middle or ee in the middle or anything that has ee and then a z like that. You can use these asterisks any place you want in there to basically find files with very complex criteria of what is in the display name.
I can expand this beyond just that folder, of course, and look to see what is available on the entire drive. You can see there is a lot of different things here. This appears here because there are two ee's and there is a y there at the end.
So you can also see how quickly it searched the entire contents of my hard drive and there are a lot of files there. In addition, I don't have to just use this piece of criteria. I can use other ones. Like, for instance, here's one I'm going to put in called Duration Seconds and I'm going to make it greater than say 600 seconds. I get, returned, a whole bunch of things. Some of these are video files and some of these are audio files that have a duration of greater than 600 seconds.
You can combine things. So I can put parentheses around this. So video files that have that I have to use programmer notation here so this two ampersands is like asking and. So durations greater than 600 seconds and the display name is going to have, say, 2005 at the beginning of it. You can see now I only get results that have all of that going on in this much longer query here.
So probably the next thing you want to know is what else can you search for besides display name and duration of media. Well, if you look in the Apple Developer site you find a list of these Metadata Attributes. There are a ton of them here. The thing to worry about is that not all of them are you going to find.
For instance, just because there is one with copyright doesn't mean that you're file has a copyright date set to it. If you create something and you've created the file and you haven't to put a copyright date there it is not going to have it or the app you are using doesn't even use this.
So a lot of these aren't going to apply. But then a lot of them will apply universally for all files. So you kind of look through these and see ones that will apply to certain types of files, ones that will apply to all files, and ones that you may never see in any files that you are currently using. But at least it gives you an idea of what is available.
I'll include a link to this URL in the Notes for this episode.
Apple Spotlight Metadata Attributes page.