Hi, this is Gary with MacMost.com. Let me show you
how you can search for files on your Mac with Wildcards.
MacMost is brought to you thanks to a great group of more than 1000 supporters.
Go to MacMost.com/patreon. There you can read more about the Patreon Campaign.
Join us and get exclusive content and course discounts.
It's fairly simple to search for files on your Mac. But I'm often asked how you can also use
Wildcards to search for part of a file name or part of the contents of a file. In most cases you
don't need to do anything special to search for wildcards. Here I am in a folder on my Mac and
I'm going to use Command F for Find. I'm not going to use the search box up here because I want to go
right to the more advanced features for what we'll do later on. So I'm going to use Command F and it
will open up a new tab in my case. Then I could see I'm going to search for Kind as Any. I'm going
to change that. So I can search for File Name and then I'm going to type part of the file name. Now
if you look at where we're searching we're not searching the entire Mac. Just inside the folder
where I started. So if I look in this folder here I can see a variety of different files.
Let's say I want to find this file right here. I can start searching for the file name and by
just typing a few letters I can find it. So as you can see it's already using one of the
most important parts of a Wildcard search. It's not requiring me to type the entire file name,
every single letter. I can type just part of it and it will come up with the result.
Now if I were to type even less you can see it gives me more. There are two files here that
start with the letter w. Now I can change matches to a few other things. Begins With and Ends With
are pretty obvious. Let's do Begins With and we see that this works in this case. I get these
two that have w in it. If I were to search for some other letter you could see it doesn't give
me anything. Now what if I were to switch to is. Well, then it's going to ask for an exact
match. You can see it still doesn't find it. But if I type the entire file name
it will find it. Notice its case insensitive. So it finds
it although there's a capital W in the name but I'm only searching for a lower case w.
Now what's the difference between Matches and Contains. Well matches is kind of the default
spotlight search. It's going to look by word and try to match the beginning of each word.
So I could start typing the beginning of the word. But
if I were to type something inside the word it won't find it. However, contains will do just
that. As I said this works per word. So let's go here and add a second word to this file name here.
So now if I were to search for the beginning of the second word you can see it finds it. But
it won't just find anything in here because I'm using matches. It's going to look at the beginning
of the word. So if I look for something inside the word like that or like that it doesn't find
it. Only if it Contains will it find something that actually is at the beginning of the word.
So what if you want to use real Wildcards to do more complex searches and maybe even do things
like search by case. Well in order to do that you need to speak directly in the language of a
Spotlight Search. All of this stuff here, filling these out, that's basically creating a piece of
code that's then implementing the search. You can skip this and go directly to create that code.
The key to do that is to use a special type of search. I'm going to go to Other here and
search for Raw and there's something called Raw Query. I'm going to select it but I'm not just
going to select it. I'm also going to Add it to the Menu so it's easy to get to in the future.
So now it says Raw Query and it's actually one of the default items in this list. So Ray Query
gives me this space here and I could type what I want. Now if I start searching for something like
that it's not going to come up with anything. It's not
a search term here. It's an actual query. So you have to specify the property you want to search
and what you want to search for. In this case we want to search for the file name.
That is in the property called kMDitemDisplayName. Then I need to do =. Technically I should do
two == but Spotlight will work with either one. Now I can put in quotes, or I don't necessarily
need to use the quotes but I will anyway, and I can do something like, for instance, wombat,
and it's not going to find it. It's looking for the wildcard which is the traditional
computer wildcard character the asterisk. But you can see it still didn't find it cause now
it's case sensitive. I need to specify capital W. That's what I'm looking for
and there you have it. You can actually make it case insensitive if you want
by after the quote put the letter c for case insensitive. Usually you add the letter d as well,
d makes it accent insensitive. So, for instance, I could put an A with the accent mark there if I
wanted to for some reason and it will still find it. If I take away the d it won't.
Now I can do all sorts of different things like, for instance, I could search for bat like that.
So it's looking for any number of letters followed by bat followed by any number
of letters. If I were to take this away from the beginning it wouldn't match it
because it's looking for something starting with bat. Now if I did file like that
it doesn't match it. But remember we have Sample File but it's not looking by word anymore.
It's actually looking for the entire name. So it will find it if I say any letters before then the
letters file and then any letters after. Then c and d to make it case and accent insensitive.
So an example of how you might want to use this is, notice here, I've got some of these images
with capital JPG after it. This can happen sometimes. So what if you just want to change
these two to be lower case and maybe there aren't three but three hundred of them. Well if you did a
search for an *.jpg" I'll get the one that's lower case. But if I search for capital JPG I'll get the
two that are upper case. It will ignore the ones that are lower case. Then I can click in here,
select All, go to File, Rename and do a batch rename of all of those changing this to that.
So that's the basics. But in addition to using something like c and d afterwards
to make it case insensitive, there's another one called w. What w will do is it will look word for
word. So we have that file called Sample Files. So if I search for f it's not going to find it.
There's nothing that starts with the letter f and then has letters after it. But if I type w
it will find it because now it's going to compare that to every word of the title.
Now before I show you some other ways to use Wildcards besides with file names
I want to show you how to combine several in one Raw Query because you can certainly add
another thing here and add another Raw Query and do it that way. But you can also use things like
parentheses and you can use and and or to look for things. So I can do an or, which in this case
is two straight up and down bars. It's the key above the Return key on American keyboards
and I could copy and paste this. Unfortunately this is very little field here but if I paste it
a second time you actually have two of these now. I can use the arrow keys to go back and forth. I'm
going to take the second one and change this to an s. So now what I'm saying here is, if the name
starts with w or it starts with s then show it. So I get all the w's and all the s's. If I change
this to two ampersands, like that, it's an and. So I'm looking for files that start with w and also
start with s which, of course, is impossible. A file name could only start with one thing.
But instead if I put a wildcard here like * t.txt I'm going to get files that start with w and end
with t.txt which only this one matches. You can also use not. Put an exclamation point before any
of these things in parentheses and it changes to a not. So it's hard to see here but there
is actually the exclamation point. So anything that starts with w and anything that does not
end with t.txt and that's how you get this result.
Okay. So names aren't the only thing that you can use wildcards for.
For instance you can use them for Tags as well. Instead of using this for a name I can do UserTags
like that. What it is going to look for now is any Tags that starts with w.
Now, of course, one of the main benefits of a system like Spotlight is you can do much more than
file name searching because you can search for the actual content of the file. That is represented
by kMDitemTextContent. So this is going to look for any content that has in it a word that starts
with the letter b. I can look for something like fo and sure enough these have a word like
that. Now if I search for something like jumps over these, which all have that word in them,
will show up. But what if I were to take away that. Well that doesn't work because there is
nothing with jump over. I can put an asterisk there and it will find it. Of course I can remove
the c here and it will be case sensitive. So I have a capital J. It's not going to find those.
But what if one of these files didn't have jumps and over right after each other,
like that. Now I can see it doesn't find it. There is no jumps over
in the watermelon.txt because it jumps nearly over. But if I put an asterisk inbetween it
then it is going to look for jumps followed by any word followed by the word over.
So there are a lot of useful things like that that you can do
to narrow down your searches using wildcards and Raw Query. However there's also a lot you
can do using just regular search using either the Matches Search
to look for words that start with some letters or using Contains to find any group of letters
in the title or the contents of the document. Hope you found this useful. Thanks for watching.