APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

2005/05/10 Smart Folders (Mac OS X)

© May 2005 Tony Lawrence

Mac's Spotlight has the ability to create "Smart Folders". If you click "Save" after doing a Spotlight search, you'll be creating a plist file which by default will be created in ~/Library/Saved Searches. It has a "savedSearch" extension, and contains the necessary information about your search:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
<plist version="1.0">
	<string>(* = "fogpr1*"wcd || kMDItemTextContent =
	"fogpr1*"cd) && (kMDItemContentType != com.apple.mail.emlx)
	&& (kMDItemContentType != public.vcard)</string>

This is a "live" folder. If you have it open in Finder, and are creating files in Terminal or anywhere else that will match the criteria, those files will instantly appear in your view.

Note that the conditional string is much more complex than anything you can type in Spotlight itself. You can use boolean logic with the command line "mdfind", and have more control with the View Options of a Spotlight search (especially be selecting "Raw Query"), but you could also manually edit this plist to get exactly what you want.

I haven't yet thought of something I really need Smart Folders for, but the idea does tantalize me. I could set up a smart folder for each customer and thus automatically track any reference in any document, no matter where I created it. I'm sure other uses will come to mind. As GetInfo now includes "SpotLight Comments" where you can add searchable metadata (it's "kMDItemFinderComment" if you are hand-rolling searches), this could get quite interesting. For example, a directory (Folder in Mac-speak) has no particular connection with the type of data you intend to store in it, but you can tag it with anything you like with Spotlight comments.

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> Smart Folders (Mac OS X)

Inexpensive and informative Apple related e-books:

iOS 8: A Take Control Crash Course

Take Control of Upgrading to El Capitan

Take Control of IOS 11

Take Control of Parallels Desktop 12

Take Control of Numbers

More Articles by © Tony Lawrence

Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

I wanted to learn how to swim, so Google showed me how to turn on the water at the sink and let me splash it around a bit. They then dragged me into a helicopter, flew way out into the ocean and dumped me out. (Tony Lawrence)

Linux posts

Troubleshooting posts

This post tagged:

Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode