Replacing login and email of many users

In my organization, the domain is soon changing from pl.xxx.com to xxx.com. Is there any possibility to change the user’s logins and emails automatically?

With the api for example this should be possible. Write a script that fetches all users and in a for…each loop or something like that look for the domain to change, alter it via regex replace for example, and push the changed user to the zammad instance.