In a nutshell, how would one access this feature in Finder – not Spotlight (Command+Space) – but the adding of tags themselves?
From Finder, highlight a file and hit Cmd-I (or right click and select Get Info) to bring up the File Info Dialog for the file. In this dialog, the Spotlight Comments field is where you add tag data. Just add text to this field to "tag" the file.
Here's a good article on how to become a meta-data wizard in OS X:
https://gigaom.com/2007/02/01/using-metadata-effectively-in-os-x/
If was tagging that screen capture, I might use the following in the comments box:
customer-name presentation product-name
So that I could find that screen shot by the customer, or by the fact that it's being used in a presentation, or by the name of the product I'm showing them.
Where are these tags stored? Do they go in .DS_Store (I tend to delete those!) or elsewhere in the filesystem?
Yes, they're stored in the .DS_Store
files you see in each folder. These files are read by Finder. The information is also stored in Extended Attributes (EAs) on the files themselves. Spotlight will prefer to read the data from EAs. EAs are a feature of the HFS+ filesystem, so remote filesystems might not necessarily have EAs available on files. In these cases, .DS_Store
files are the fallback. Spotlight would also have a tag <-> file mapping section in its database but that's only accessible to Spotlight.
Does this tagging mechanism work on removable drives? What are the requirements?
Generally: yes. You can add tags to files and folders on removable drives and remote shares. Unless you've turned off .DS_Store
creation on remote shares, OS X will just add these files and keep the meta-data there for you.
Does this tagging mechanism work over a network share? I have some Windows SMB network shares at home that I frequently store files on. Would it work on those or is another configuration required?
Yes, see above. If you didn't want OS X to do this, run:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
And then restart Finder.
Aside from Spotlight, are there any command-line tools for searching through or accessing the tag data for files?
Lots!
Here's a list of 7 file-tagging applications for OS X: http://mac.appstorm.net/roundups/utilities-roundups/7-file-tagging-applications-for-os-x/
I personally love and use LaunchBar which is like Spotlight on steroids.
Here's two commands that lets you copy tags from one file to another.
xattr -wx com.apple.metadata:_kMDItemUserTags \
"$(xattr -px com.apple.metadata:_kMDItemUserTags /path/to/original)" /path/to/copy
xattr -wx com.apple.FinderInfo \
"$(xattr -px com.apple.FinderInfo /path/to/original)" /path/to/copy
You can iterate through various files to copy the tags to multiple destinations. For applying the above to various files based on the results of a find command (which lets you automatically iterate through results of various searches), see my answer here:
Here is a small bash script using the previously mentioned commands. You can use it, for example, in Automator.
#!/bin/bash
# copy Tags from 1 file folder to the next
TAGS_FROM="$1"
TAGS_TO="$2"
if [[ -e "$TAGS_FROM" ]] && [[ -e "$TAGS_TO" ]]; then
xattr -wx com.apple.metadata:_kMDItemUserTags "$(xattr -px com.apple.metadata:_kMDItemUserTags "$TAGS_FROM")" "$TAGS_TO"
xattr -wx com.apple.FinderInfo "$(xattr -px com.apple.FinderInfo "$TAGS_FROM")" "$TAGS_TO"
else
echo "Unexpected input, usage:"
echo "$(basename "$0") /path/to/original /path/to/copy"
exit 1
fi
Here is an example of an automator/apple-script (still using the bash commandline...). First set some attributes for this automator.app, then drag a file onto the app. The file will then copy the attributes from the automator.app to itself. I am no Applescripter, so improvement is always welcome.
Best Answer
You can delete custom tags you created by going to "Finder-->Preferences-->Tags" Then highlight the tags you don't want. (To select multiple at once click one and then shift+click the last one). Right-click and "Delete # Tags".
In your case, with 70+ tags, just use select all from the edit menu (Command A) to select all the tags. Then hold the option key to click the 6 tags you want to keep. Once the rest are selected you can mass delete them, leaving the few tags you prefer.