You can record action what is not very difficult but... Actions have limitations, you can use action only in documents where layers/groups have exactly same names as when actions is recorded or you must have exactly same layer structure all the time.
I am not aware of script nor I am capable of writing one, please wait for script guys who may be able to help you.