You need to hook up a behavior to addition of Node. An example of exactly what you are trying to do is in the Records Management module. Basically, when you add a new record, it automatically renames it by prepending a generated Record ID, which seems very similar to what you want.
I don't remember exactly which one does it, but follow the behaviors defined in this file to see how they did it: SRC\modules\records-mgmt\config\alfresco\module\org.alfresco.module.RecordsManagement\context\behaviour-context.xml
You need to hook up a behavior to addition of Node. An example of exactly what you are trying to do is in the Records Management module. Basically, when you add a new record, it automatically renames it by prepending a generated Record ID, which seems very similar to what you want.
I don't remember exactly which one does it, but follow the behaviors defined in this file to see how they did it: SRC\modules\records-mgmt\config\alfresco\module\org.alfresco.module.RecordsManagement\context\behaviour-context.xml