I mentioned on Twitter a couple days ago that I was mulling a switch from EagleFiler to a pure file system-based approach leveraging OpenMeta tags. Long-time readers may recall that it was only September of last year that I switched to EagleFiler from Yojimbo, my previous “anything bucket”. My decision to switch away from EagleFiler is not a reflection on the application itself; it’s a great application. For me, it just seemed as if EagleFiler was duplicating functionality I could already get with just the file system, so what’s the point? Plus, as I increasingly keep data synchronized across multiple systems, EagleFiler wasn’t as friendly to my data synchronization solutions as I would have liked. A file system-based approach leveraging OpenMeta tags is perfectly happy with both Dropbox and Unison.
The OpenMeta tags are really the key; using OpenMeta tags, I can set up saved searches that easily let me drill down to only certain subsets of files regardless of where on my computer those files might be stored. However, the problem that I was running into was that the Mac OS X GUI did not provide a way for me to find all untagged files (obviously, the key to making tags work effectively is using tags everywhere). For that, I had to drop out to the OS X command line and use the mdfind command, like this:
mdfind -onlyin ~ "kOMUserTags != '*'"
The kOMUserTags is the name of the extended attribute in which OpenMeta tags are stored. This particular query finds files that don’t have any OpenMeta tags. Unfortunately, there didn’t seem to be any way to bring this query (and the query results) into the GUI.
After some further experimentation, I grew frustrated with how things were progressing (or not progressing, in this instance) and thought I’d try to dig up some documentation on the syntax for mdfind. I didn’t find the documentation—but I did find this page, which gave me two important pieces of information:
-
It showed me the syntax to query on both filename as well as extended attributes at the same time.
-
It showed me how to bring these queries into the Finder GUI.
Let’s take a look at the first one. To query on both filename and one or more extended attributes, you can’t use the -name parameter to mdfind. Instead, you have to use this syntax:
mdfind -onlyin ~ "(kMDItemFSName == '*.txt') && (kOMUserTags != '*')"
That query will show you all the text files that don’t have any OpenMeta tags applied. Obviously, you could customize the filename specification or the particular extended attributes you wanted to search, but you get the idea.
The second thing I found was how to bring these advanced queries into the Finder GUI. The trick is in enabling “Raw Query” on the pop-up menu in the Spotlight search menu:
- Open a Spotlight search window by pressing Cmd-F while Finder is active.
- Click the “Kind” pop-up menu and select “Other…”.
- It may take a moment, but in a bit a window will open with all of the various types of Spotlight metadata. Scroll through the list to find Raw, then place a checkmark in the “In Menu” column. (By the way, this is also how to add Tags to the menu for use in Spotlight searches.)
Now, in a Spotlight search window (and that includes new Smart Folders), you can click the pop-up, select Raw Query, and then type your raw mdfind query like the one above, and it will be displayed in the Finder. Cool! Using this Raw Query support allows me to build extremely sophisticated Smart Folders.
For example, I’ve already shown you the query to list all untagged files (very first example in this post) and the query to list all untagged files of a certain type (second example). Here’s the query to list files that have one tag but not another tag:
mdfind -onlyin ~ "(kOMUserTags == 'Tag1') && (kOMUserTags != 'Tag2')"
You could, naturally, combine this with a filename filter to get even more specific. I hope this helps someone else out there fine tune their Spotlight searches as well!
Tags: CLI, Macintosh, Productivity
-
You can find untagged files simply with HoudhSpot.
-
Sorry, I meant HoudahSpot.
-
Scott,
I saw your post pop up on my smartphone’s gReader app. I saved it for later reading. Later finally came.
I’m fascinated with the idea of proper tagging. I’ve been struggling with a tagging strategy in Evernote for some time. And I have used ampersands in files’ “info” displayed by Finder to serve as a kind of tag search. For instance, the VPLEX PPT you gave me over a year ago has the word “&lowe” in the file’s info. I can find it with a spotlight search on that “tag”.
But ultimately I find–even after months of neurotic obsessive tagging–that I never use the tags. Which brings me to The Big Quesion: do we really need tags? The Internet is not tagged and Google works great.
I’d be interested to hear your thoughts.
Scott
-
You can search for all untagged OpenMeta files in Leap by using the ‘Untagged files’ option. First you will want to select a folder or filetype, though as computers have 2 million files, all of which are untagged!
Also you should be using kMDItemOMuserTags – not kOMUserTags. The kOMUserTags is there for backwards compatibility. Spotlight indexes tags using kMDItemOMuserTags.
If you install Tagit, then run it once, you will now be able to search for tagged documents in the Finder using ‘tag:apple’ for example.
–Tom Andersen
ironic software -
I activated the Tags query item in the same manner that Scott describes above for activating the raw query syntax in Finder searches. I then searched for a tag that I had applied to some files and saved the result as a saved search (smart folder). Opening the saved search file in BBEdit shows that the search uses kOMUserTags rather than kMDItemOMuserTags. Just for the sake of experimentation, I ran a search-and-replace on the file replacing all occurrences of kOMUserTags with kMDItemOMuserTags. When I saved it and tried to open it as a smart folder in Finder, it consistently crashes the Finder.
One thing I noticed is that the Tags option actually appears twice in the list of available “other” metadata. I did try setting each of them separately, but they both create searches based on kOMUserTags. I also tried raw query searches using both options and found that kOMUserTags succeeds while kMDItemOMuserTags does not.



6 comments
Comments feed for this article