Using xattr on the CLI you can write arbitrary metadata to files. This is useful for other CLI scripts because you can search for these arbitrary attributes using mdls. However, if you want to set metadata that is easily searchable in applications like Finder, you have to set the values for existing attributes.
$ xattr -w "com.apple.metadata:kMDItemStarRating" "10" filename
http://hints.macworld.com/article.php?story=20110314131100623