Dynamically Change Screenshot Save Location (based on time/front app)

See this macro. It is not exactly what you are asking for, but should give you a good basis to build what you want.

BTW, I easily found this macro, by clicking on the "screenshot" tag at the top of this page.