Search This Blog

Thursday 22 November 2012

Mac 101: Seek and find



As we meander down life’s path, we tend to pick up bits of this and that. And, over time, these things pile up to the point where, if we’re not organized, we lose track of them. And this often results in cries of “Honey/Mom/Dad/Jeeves, have you seen my glasses/lunchbox/dueling pistols!?” Wouldn’t it be great if the answer was more helpful than, “Well, where did you last see them?”
While there may be little we can do about locating these kinds of physical treasures, we needn’t have that happen with the files and folders on our Macs. And to prevent exactly this kind of thing, Apple has brought us Spotlight, technology built into OS X that allows us to easily find the items we seek.
It works this way: When you first install Mac OS X, Spotlight kicks into gear and begins indexing the contents of your drive. It keeps track of not only the names of your files and folders, but also their contents, the day and time each was created, the kind of files they are, and much more. As you create new files and folders, Spotlight indexes them as well, adding all this information to a hidden database file that it can later query to help you locate the stuff on your Mac.
And how exactly do you locate that stuff? Let me enumerate the ways:

Spotlight menu

In the top right of the Mac’s menu bar you’ll spy a magnifying glass icon. This denotes the Spotlight menu. Click on it and the menu appears, complete with an empty Spotlight field. It’s into this field that you type the first few letters of what you seek. For example, if you have a document somewhere on your Mac that details your grandmother’s recipe for mocha meatballs, entering mocha in this field will likely produce the file you’re after (though others that contain the word mocha will appear as well). These files are categorized by type—Documents, Messages & Chats, Contacts, Events, Images, Music, PDF Documents, and Presentations, for example. If you know the type of file you’re looking for, you can ignore other kinds of results.
Once you’ve found the file you’re after, you can click on it to launch it within the application associated with it. Or, if the highlighted result is the correct one, just press Return.
But what if you’ve entered a search term, a list of documents appears, and you’re still not sure which is the right one? Just hover your cursor over a file to highlight it, and a small preview window will appear that shows you some of the contents of that file. If it’s what you’re after, press Return to open it. If not, highlight another document and wait for its preview to appear.

Limiting searches

“But hang on,” you say. “When I do this, I see lots of results. Is there any way to limit what appears to, say, the exact title of the file you want?”
Yes, indeed. Just enclose your search in quotes. For instance, if you want to find a document titled Grandma’s Mocha Meatballs, surround your search in quotes: “Grandma’s Mocha Meatballs.” Only those files that match this exact phrase will appear.
“Sorry to interrupt yet again,” you interrupt yet again, “but surely there must be a way to limit those searches so that I can see just results that fit a certain category.”
Use keywords to limit your searches
There is. Spotlight will filter by keyword. Keywords can include terms like name, kind, date, author (the person who created the document), and so on. For example, if I were looking for image files that included my name in the title I’d enter kind:image breen. (The format is important: Leave no spaces between keywords and the colon, and then enter a space and type the search term or phrase.) And you can gang together keywords. If I wanted to find image files with just my name in them that were created today, I’d type kind:image date:today breen.
You can additionally create Boolean searches. (Named after 19th century English mathematician George Boole, who made my high school years less enjoyable.) The general idea is that you can alter what you’re looking for based on true or false conditions. In Spotlight this means using AND, OR, and NOT within your searches (and no, I’m not yelling at you, the words must be in all capital letters.)
For example, if I wanted to find something that included both sandwich and aardvark,I’d enter into Spotlight sandwich AND aardvark. Any items that include both terms will appear in the list of results. If I instead enter sandwich OR aardvark, the results will include any items that include either of these terms. And if I type sandwich NOT aardvark, I see only files that include sandwich but make no mention of Africa’s ant bear.

Hobbling searches

If you find there are certain kinds of results you see time and again that hold no interest for you, you can filter out those results. To do that, choose Spotlight Preferences from the Spotlight menu. (Or click on the Apple menu, choose System Preferences, and click on Spotlight in the resulting window.)
In the Spotlight window that appears, click on the Search Results tab if it isn’t already selected. Below is a list of items that Spotlight will search for. Uncheck those that you don’t wish to appear in the results list. For example, if you find your results cluttered with email messages that you don’t intend to search, uncheck the Messages & Chatsitem. If webpage search results hold no interest for you, uncheck the Webpages item.
Tell Spotlight what to search through and what to ignore.
You can also keep Spotlight from searching certain locations on your Mac. To do that, click the Privacy tab and then click the plus-sign button (+) at the bottom of the currently empty list. In the sheet that appears, navigate to the folder that you don’t want to search—your Downloads folder, for example—and click Choose. That folder will now be excluded from searches. You can exclude additional folders by repeating this process.
Why would you want to do this? Perhaps someone else uses your Mac and, specifically, does so using your user account. If you have files that you’d like to keep more-or-less private, placing them in a folder that’s then excluded from search will prevent sensitive files from being easily exposed to other people via Spotlight. If this person has an account of their own, you needn’t be concerned. Spotlight will not search the contents of other users’ accounts. (I’ll talk a lot more about users and having multiple user accounts on your Mac in an upcoming column.)
While you’re looking at the Spotlight window, note the two keyboard shortcuts at the bottom. By default, you can invoke Spotlight by pressing the Command key and spacebar. If instead you want to open a search window (which I’ll discuss shortly), press Command-Option-Spacebar. If you like, you can change these keyboard shortcuts by clicking on the arrow next to the shortcut and choosing another shortcut, or you can simply highlight the shortcut and press the keys that you’d like to use instead.

But wait, there’s more…

You can do more with this Spotlight menu than just conduct searches. You can, for example, launch applications. To do that, just start typing the name of the application you want to open. When its name appears in the Spotlight menu, highlight it and press Return. The application will open.
More? Okay, enter a word whose definition you want. Near the bottom of the menu, you’ll see a Look Up entry, followed by the icon of a book. Highlight this entry, and the definition of the word will appear in a preview window.
Use Spotlight to quickly look up a word's definition.
At the bottom of the menu, you’ll see a Web Searches item. Next to it are entries for searching the Web as well as Wikipedia (the online encyclopedia). This indicates that Spotlight can do more than help you search your Mac. It can also search the Web.
Enter a term or phrase you’d like to know more about and choose 'Search Web Foryoursearchterm', and Apple’s Safari Web browser will open and show you the results of your search. Similarly, if you want to visit Wikipedia only, choose 'Search Wikipedia for yoursearchterm'. Off you’ll go with Safari.
Can’t seem to find your calculator? No problem. You can enter calculations in the Spotlight field as well. Go ahead, enter (8 + 2) * (100 / 17). The first result will read 'Calculator 58.8235294'.
Finally, take note of the Show In Finder command at the very top of the Spotlight menu. As hard as you’ve tried to narrow your search, you still see a list of results that doesn’t include the item you’re looking for. Choose Show All In Finder, and a window appears that lists all matching items on your computer. Depending on how many files you have on your Mac (and this includes email messages), that list could number in the tens of thousands. And this leads us to another kind of search you can perform with your Mac.

The Find command

Once upon a time, we searched our Macs not with the fancy-schmancy Spotlight, but with the Find command found in the Finder’s File menu. That command remains, but because it’s now tied to Apple’s Spotlight technology, it’s a far more effective tool than it once was. To invoke the command within the Finder, just press Command-F.
A Searching “This Mac” window appears by default. This window contains a Search field at the top (as does any Finder window). To begin a search, just enter your search terms in this field. As with the Spotlight menu, you can narrow your search using quotes and Boolean conditions. (You can’t do math, look up words in the dictionary, or launch applications, however.)
Type your search term, and a menu will appear that reads 'Filenames' at the top. Below are the words 'Name Matches'. For example, Name Matches: Sandwich. Choose this and your results will include only items that contain your search term or phrase in the file’s name. If you don’t do this, your search results will include any files that contain the term or phrase you seek, even if it’s within the body of an email message, for example, or is a keyword within an image file.

Narrowing your search

You can broadly narrow your search in another way. Just under the toolbar, you’ll see the word Search: followed by This Mac, “Desktop”, and Shared (assuming you conducted this search while the desktop was active). Choose This Mac and a search will be conducted across the length and breadth of any volumes and hard drives attached to your Mac—almost. (I’ll explain the almost in a bit.) Select “Desktop” and only the desktop will be searched. And, as you can likely guess, if choose Shared, the Mac will search just the computers on your network that you’re allowed access to. (We’ll get to sharing eventually, so if this confuses you, don’t worry about it for now.)
The second entry in this list—“Desktop”, in the case of our example—will change depending on the active window you’re working with. So if you’ve opened the Documents folder and then entered something in the search field, that second entry will read “Documents”, reflecting your current location in the Mac’s file hierarchy.
You can think of it this way: Imagine that you need to find something in your home. The first This Mac entry would be like searching your entire living space. If you instead move to your bedroom and conduct a search, the second entry would read“Bedroom”, indicating that you’re going to confine your explorations to the room in which you’re currently standing. Shared would be similar to having the key to your neighbor’s apartment and rummaging around in their underwear drawer.

Really narrow your search

“Chris, dude, this really isn’t cutting it. Even with the ability to search just these locations, I’m seeing too many results!”
Indeed you are. As I said, this is a way to broadly narrow your search. Let’s get more specific.
If you like you can use exactly the same kind of keywords I described earlier—kind:image date:today sandwich. But the Search window allows you to do this kind of thing without memorizing keywords or ensuring that you’ve formatted them correctly. Notice the small plus-sign button (+) that appears next to the Save button near the top right of the window. This is the key to creating narrower searches.
Using the Finder's Find command.
Click it and you see two pop-up menus—Kind and Any. Click on the Any pop-up menu, and choose Image. All the images on your Mac or within your current location within the hierarchy appear, as does an All pop-up menu. Click on All and choose PNG. Now only those images in the PNG format appear.
“Okay, that’s closer, but I want just the images of aardvarks in PNG format.”
Fair enough. Click the plus-sign button again and choose Name from the first pop-up menu, Contains from the second menu, and enter aardvark in the search field that appears after the Contains pop-up menu. Only images that contain the word aardvarkin their name and that are in PNG format will appear in the list of results. To open the one you want, just double-click on it.
Using this “click the plus-sign button” technique, you can create quite narrow searches.

Really, really narrow your search

Still not enough? Let’s dig deeper!
Create a new window in the Finder (press Command-N). Enter a search term in the search field and click the plus-sign button. From the Kind pop-up menu, choose Other.So, what is Other?
That, my friends, is a sheet that includes an exhaustive list of the kinds of things you can search for. Want to search for images for which you applied red-eye correction in iPhoto? You can. Seeking only songs tagged with the merengue genre? No problem. Curious to see a list of the third track of each album you have in your iTunes library? That’s possible as well. Select the condition you want and click OK, and that condition will appear in the pop-up menu. And if you routinely use these kinds of conditions for searching for files, you can add them to the pop-up menu’s list of choices simply by enabling the In Menu option to the right and clicking OK.
Search using an exhaustive list of conditions.
Now, remember earlier when I said, "Choose This Mac and a search will be conducted across the length and breadth of any volumes and hard drives attached to your Mac—almost"? Neither Spotlight nor the Find command will show you all the files on your Mac. Apple has determined that some files should not be messed with and has therefore hidden them. They are likewise hidden from these kinds of searches. However, you can make some of them visible. Like so:
Return to that sheet of search terms, and in the sheet’s search field enter System. A single entry, named System Files, will appear. Enable the In Menu option and clickOK. When you click on that pop-up menu, you’ll see a new System Files entry. Choose it and configure the second pop-up menu to read Are Included. When you now conduct a search, the files normally hidden from you will appear in the list of results.
Since the intended audience for this column is people who are just discovering the deeper wonders of their Macs, I will issue this warning: Until you’re very sure about what a particular file does, don’t mess with it. Apple has hidden those files for good reasons. You may eventually get to the point where you can confidently root around in your Mac’s hidden directories, but it’s likely you’re not there yet. If not, tuck this knowledge away for the day when you’re ready. (Keep following along each week, and I’ll tell you when that is.)


No comments: