In OS X, you can tag files using various tools such as Hazel, Default Folder X, Tags, DevonThink and others. The process of tagging consists into attaching keywords to your files so they can be retrieved easily later.
Today I will discuss how I use Hazel and its embedded scripting capabilities to automatically apply tags to files. First, Hazel is a commercial tool that you configure to watch specific folders on your MAC and then take actions. For instance, you can have Hazel to monitor the Downloads folder and then move files to specific vendor folders, e.g., Cisco folder, Fluke folder, etc… As of this writing, Hazel does not have an option to apply tags as an action. But, it does have the ability to either call an AppleScript or Shell script. And this is how I achieve auto-tagging.
All my project notes are stored in text files or better, RTF (Rich Text Format) files. I maintain a structure by project, sub-project, etc, as follows:

The goal of this structure is to have tags applied automatically to files based on the directory path. For instance a file saved under directory NOTES -> PROJECT-NOTES -> LAB -> ASA would have the following tags applied by the Hazel script: notes project-notes lab asa
Here is how it is achieved. I have Hazel to watch the NOTES folder as follows:

Under rule TAG-IT, I defined the following:

Which means that every file added in the last minute that passes the embedded script will trigger a Grow notification. The embedded script always passes since it terminates with <exit 0>. I use a Shell script to achieve this. Here is a partial view of it after you click the <Edit script> button:

At the end of the script, the openmeta command line tool is invoked and will apply the tags to the file that was just added to the sub-directory. This tool is free and can be used independently from Hazel.
I can then retrieve my tagged files with Ammonite (highly recommended tool)

In the above example, I searched for asa lab notes and 1 hit was found.
You can download my shell script here: embedded-script.sh
If you are interested in tagging, I suggest you read Greg Ferro's excellent blog posts:
My Knowledge Management Process With PDF Files – Part 1
My Knowledge Management Process With PDF Files – Part 2
Happy tagging!