Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Unleash Spotlight through Other and Raw queries Desktop
Tiger only hintI haven't really read about anyone using the "Other..." option in the query field of a Finder Search. In Finder, open up a window and type Command-F to get the search. Then pop-up one of the query buttons with "Kind", etc, and choose "Other..." at the bottom. There are dozens of kinds of query types, and you can add favorite ones to the main menu. An interesting one is "Raw Query," which lets you type in mdfind-style command-line queries!

If you select a favorite file and in the Terminal do mdls filename, where you replace filename with the name of the file you're interested in, you can see the attribute types that MacOS tracks. Looking at a Quicktime movie, for instance, I see 30 attributes that are currently maintained automatically for us. These include the name, the codec used ("Motion JPEG A"), when the file was created, when it was last accessed, when it was last modified, when its attributes (as opposed to content) were last modified, its kind ("Quicktime Movie"), its media type (Video), its pixel height and width, its bitrate, and much more. (You can add your own metadata in several ways, including using Get Info's Spotlight Comment field.)

For example, to find all movies that are nine seconds or longer, use this raw query:
 mMDItemDurationSeconds >= 9.0
As you can see, this is very powerful...

[robg adds: I realize many of the Spotlight query hints I've run are somewhat similar, have overlapping content, etc. But for now, since it's both so new and so powerful, I feel it's best to get as many tips out there as I can that have at least some amount of unique content. Apologies in advance if I mess up and publish a true duplicate or two!]
    •    
  • Currently 2.00 / 5
  You rated: 3 / 5 (4 votes cast)
 
[12,847 views]  

10.4: Unleash Spotlight through Other and Raw queries | 8 comments | Create New Account
Click here to return to the '10.4: Unleash Spotlight through Other and Raw queries' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Unleash Spotlight through Other and Raw queries
Authored by: club60.org on May 11, '05 12:26:41PM

I am still wondering how to use raw queries with dates. What is the correct format to search files modified today? Or on some specific date?

(kMDItemContentModificationDate < ...) && (kMDItemContentModificationDate > ...)



[ Reply to This | # ]
Yes, I do!
Authored by: dtrevas on May 11, '05 01:37:52PM

To do date/time comparisons you need to use some ISO format like this:

$time.iso(20050511T132342)

which is:

1. The four digit year (2005)
2. The two digit month (05, May)
3. The two digit day (11)
4. The letter 'T'
5. The two-digit 24 hour time(13, 1:00 PM)
6. The two digit minute(23)
7. The two digit seconds(42)

That seems to work. Now if somebody will expound on the difference between the kMDItemContentCreationDate and the kMDItemFSCreationDate, I'll be happy.



[ Reply to This | # ]
Yes, I do!
Authored by: spullara on May 11, '05 02:10:46PM

Sounds like they meant Content Creation Date to be when you started working on it in the application that created it while the other one is when it was first written to this filesystem. I could see how this would be good for searching for photos or movie data as it was created long before it was written to your filesystem.

---
"The messiness cannot go into the program; it piles up around the programmer." -- Ellen Ullman, Close to the Machine



[ Reply to This | # ]
FSCreationDate vs. ContentCreationDate
Authored by: danielj7 on May 11, '05 05:58:04PM
kMDItemFSCreationDate is the date that the filesystem records as being when the file was created. kMDItemContentCreationDate would be when the content of the file was created and is stored as part of that content. The two should usually be the same, but could get out of sync for various reasons, e.g. if the file is duplicated, the FSCreationDate might change while the ContentCreationDate would stay the same.

[ Reply to This | # ]
10.4: Unleash Spotlight through Other and Raw queries
Authored by: fud on May 11, '05 02:44:15PM

I wanted to create a Spotlight smart search that would list files by date added to my harddrive. I tried all the date related options in the "other" popup menu until resorting to the "Raw Query". This seems to be close to the results I wanted:

kMDItemAttributeChangeDate > $time.this_week

You can set the View Options to Group by Date, and the Folder "Downloads", which gives me a Spotlight search sorted by the date files were added to my downloads folder.



[ Reply to This | # ]
10.4: Unleash Spotlight through Other and Raw queries
Authored by: zzzmarcus on Jun 26, '05 07:59:59PM

You can do this in Firefox by browsing to a page with Quicktime movies going to tools > page info (cmd + i) the media tab and then scrolling through the list until you see a url ending in .mov with the type "embed." Click "save as" as the bottom and you're done.

http://marcusvorwaller.com



[ Reply to This | # ]
10.4: Unleash Spotlight through Other and Raw queries
Authored by: zzzmarcus on Jun 26, '05 08:01:19PM

oops... posted to the wrong thread.. should have been here:
http://www.macosxhints.com/article.php?story=20050430173712176



[ Reply to This | # ]
10.4: Unleash Spotlight through Other and Raw queries
Authored by: raider on Oct 11, '05 11:09:29AM
I submitted a hint on a related set of information, but this is also relevant to this hint.

Two helpful links:

Spotlight's query expresion syntax.

and

Spotlight Metadata Attributes

[ Reply to This | # ]