i think i found another thread with a viable solution.
that should get you started and is a better option than i came up with, see below for a very unoptimized script. haha