Hi you might be interested in this. I build it for LaunchBar. But since it is just an applescript you should be able to make it work just fine in Alfred with just a few changes. It's a few lines of code. But it should cover pretty much all the bases.
use framework "Foundation"