OS X: Bulk Rename Computers That Are Being Repurposed

Whenever I get a bunch of new computers and phase out some old ones, I typically want them to have the same name.  Since I do not want duplicates, I just prepend (or append) “Repurpose-” to the computer name.  Then, I can name the new computer with the same without any conflicts.  Finally, I update the JSS record of the computer to change it’s building to “Recycled.”  Below is the script I use to do this.

If I want to set the new computer names, I do this in a similar fashion.