I did it manually (~50 devices at the time). If there is a way to automate it, I am not aware.
On the bright side, it was a good chance to update the names on all the devices so they follow the same naming convention.
Then of course, I needed to update all automations and Dashboards to use the new device names.