Actually, your original post didn’t explicitly state that you were attempting to write a script, per se, and since most questions here *would* pertain to expressions rather than scripts, I think it’s an oversight that can be forgiven, no?
Did you not have any luck with your question over at aescripts.com?
Because if you can get help with scripting anywhere, it’s there. Perhaps you need to think of alternate ways to achieve the result you’re after.
It’s only work if you’d rather be doing something else…