Rename Home Folder

steve_summers
Contributor III

Greetings. Would anyone have a working script to rename a customer's home folder? In our environment Macs are named with the actual user name. (boo-hiss..I know...) And as you can imagine, people's name change ever so often. It's a total manual process and I'm looking to automate it as much as possible. I have changing the computer/host name scripted and working, but the home folder is a different animal. I've read of using dscl . create but not sure if that's needed.

Is it possible to simply rename to the new name and boom, done, as long as the customer is not logged that is? Thanks compadres..

3 REPLIES 3

justin_smith
New Contributor III

You would need to remove the user record first using

sudo /usr/bin/dscl . -delete /Users/$youruserhere
rename the home folder to their current name
Make sure the permissions are correct
login as the user

steve_summers
Contributor III

Thanks @justinssmith I'll test that tomorrow!

ibrahimag
New Contributor

Hey @steve.summers !

New here! was wondering if you ever found an easier way around this. If so, it'll be great if you can share here. Thanks!