First you need subl
at the command line. Use this:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
...which came from Sublime's documentation here.
Next, open (Apple)Script Editor and paste this in:
tell application "Finder"