We had to do this for student email addresses when we switched to O365. Write a script in PHP. Something like:
<?php
$db = MySQL_connect('dbserver','dbusername','dbpassword'); //check your siteroot/config.php for this info
$db = MySQL_select_db('dbname',$db); //dbname will also be in config.php
$users_sql = "SELECT id,username FROM mdl_user WHERE username LIKE '%@k12.xx.us'";
$users_query = MySQL_query($users_sql);
while( $user = MySQL_fetch_object($users_query) ) {
$new_username = str_replace("k12.xx.us","xx.org",$user->username);
$update_sql = "UPDATE mdl_user SET username='" . $new_username . "' WHERE id=" . $user->id;
echo '<p>Updating email address ' . $user->username . ' to ' . $new_username . ' for user ID ' . $user->id . '</p>';
//uncomment the next line when you have run the script and checked it will do the correct thing for all users
//MySQL_query($update_sql);
}
?>
This will look in the username field of all of your users (who have @k12.xx.us in the value), go through each one and amend the email address. And tell you what it's doing.
When you've put your database details in the 2nd and 3rd lines, and run it in a browser to check it'll work correctly, then uncomment the 3rd from last line (MySQL_query to run the update).
NOTE - the word MySQL in the above script is actually meant to be in lower case - the forum editor is autocorrecting it.
HTH