If I understand correctly, you want a script that will set the external id of every created/edited record to the same value as the record name. It can be done via a trivial user event script for all record types that support one, and possibly even with a workflow.