APLawrence - Information and Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds Get APLawrence.com by RSS











(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Home > foo-mac > Tiger's Smarter Folders
Printer Friendly Version






Tiger's Smarter Folders

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 using Spotlight comments. If you choose "Get Info" for a Tiger folder, you'll see that you can add Spotlight searchable comments to the folder. This could be useful (assuming that you use Spotlight at all). For command line searching, you'd use "mdfind" and if you want to be specific about searching comments, use "kMDItemFinderComment":


 $ mdfind 'kMDItemFinderComment == "script application wrapper"'
 /Users/apl/Desktop/platypus Folder
 
 

Of course you can add Spotlight comments to any file also, but I think the folder tagging opens up more interesting possibilities. Using mdfind and some scripting, you could control misfiling: if a document doesn't match the comments property of its folder, it may not belong there. Combine that with monitoring directory changes and you can get quite a bit of automatic error checking for file storage.

Spotlight also 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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 
 <dict>
         <key>CompatibleVersion</key>
         <integer>0</integer>
         <key>RawQuery</key>
         <string>(* = "fogpr1*"wcd || kMDItemTextContent = "fogpr1*"cd) && (kMDItemContentType != com.apple.mail.emlx) && (kMDItemContentType != public.vcard)</string>
 
         <key>SearchCriteria</key>
         <dict>
                 <key>AnyAttributeContains</key>
                 <string>fogpr1</string>
                 <key>CurrentFolderPath</key>
                 <array>
                         <string>/Users/apl</string>
 
                 </array>
                 <key>FXCriteriaSlices</key>
                 <array>
                         <dict>
                                 <key>FXSliceKind</key>
                                 <string>Skin</string>
                                 <key>Value</key>
 
                                 <string>KI**</string>
                         </dict>
                         <dict>
                                 <key>FXSliceKind</key>
                                 <string>Slsv</string>
                                 <key>Value</key>
                                 <string>DA**</string>
 
                         </dict>
                 </array>
                 <key>FXScope</key>
                 <integer>1396926573</integer>
                 <key>FXScopeArrayOfPaths</key>
                 <array>
                         <string>kMDQueryScopeHome</string>
 
                 </array>
         </dict>
         <key>Version</key>
         <string>10.4</string>
         <key>ViewOptions</key>
         <dict/>
 </dict>
 </plist>
 
 


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.

For example, if you have customers or clients, you could set up a smart folder for each customer and thus automatically track any reference to a particular customer in any document, no matter where you created it.


Technorati tags:

If this page was useful to you, please click to help others find it:  
Your +1's can help friends, contacts, and others on the web find the best stuff when they search.


Comments?




More Articles by Tony Lawrence - Find me on Google+



Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



LOD Communications, Inc.

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

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. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!


book graphic unix and linux troubleshooting guide




Buy Kerio from a dealer who knows tech: I sell and support

Kerio Connect Mail server, Control, Workspace and Operator licenses and subscription renewals
pavatar.jpg

This post tagged:

       - MacOSX




Unix/Linux Consultants

Skills Tests

Guest Post Here