Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming Users Home Directory ??

Status
Not open for further replies.

quinla01

IS-IT--Management
Nov 1, 2005
20
0
0
GB
K, here’s a tricky one,

For some reason, the previous member of staff set up the home directory’s for users in strange format:

\\filestore101\users$\SiteName\UsersInitials

Eg. \\filestore101\users$\Site1\AQ1

In some cases there's even a site sub directory

EG. \\filestore101\users$\site1\HR\Aq1


Now this is causing a bit of a problem since i plan on migrating the data to a new file server. Now ideally, what I'd like to do is flatten the structure (i.e. no more subdirectories in the users$ share).
This would be simple enough if the users home directory was named after their username since i could simply flatten the structure and run a batch file to rename the home directory path to \\filestoreNew\users$\%username% however the user's folders are named in a completely random manner eg \AQ1 or \AQ01

So I’ve got a few options, non of which are ideal when you consider i have 800 users.

option 1) Recreate new users folders using the %username% command, then copy the contents manually from the old users folder to the new folder.

option 2) flatten the structure and keep the old folder names and then rename the path to the users home directory

I was wondering if anyone has a script or knows a programs that will rename a user home directory based on their username or if anyone has any other solutions to my problem.

Thanks

Andy


 
OK I know this isn't exactly what you're looking for, but it can get you part way there. No matter how you do this I think it's gonna involve some manual work because of the way the directory is currently setup. Anyway, you can use a for loop in a batch file to create the users current directories like so:
Code:
for /F %%a in (%1) do mkdir %%a
goto END
:END
Call the file makedirs.bat or something like that and then call it by saying makedirs.bat new_user_names.txt (just make sure they're both in the same directory or else use absolute path names). All you need to do is create a list of the usernames - or if you already have everybody's firstname and lastname in AD then you can use excel to calculate it by using various functions (if you need help with that post back).

You could also add another line in the script that set the permissions using cacls - you'd just have to make sure that the account existed first obviously though !!

I know this isn't exactly what you're after, but I couldn't find a way of incorporation the old username also so that you could rename it. I think VBS would probably be able to do this, but I haven't got the time to look it up at the moment and I'm pretty new to that language. Let me know how it goes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top