Script to migrate specific user subfolders?

March 24, 2011 at 08:22:56
Specs: Windows XP
Im helping migrate some user profiles at a hospital and basically they only require to be saved the Desktop, Documents, Favorites folder, then appdata\microsoft\outlook ,appdata\microsoft\signatures, localsettings\appdata\microsoft\outlook and the ntuser.dat
Thats it. So far its tedious going into each folder manually to check if they have data as some of these workstations have been up since 2003 and have 100+ user profiles.

Or anyone recommend a good tempfolder cleaner because so far I have a java one that randomly stops. I try to use that and then robocopy.
But if I could just nab those few critical folders they want, that would be better.
Or a copy that ignores those..

See More: Script to migrate specific user subfolders?

Report •

March 24, 2011 at 12:36:32
Robocopy has this already. Have you tried the options? It would be something like...

robocopy "c:\documents and settings\yourname\" "yourdestination" *.* /XD "c:\documents and settings\yourname\AppData" /XD "%userprofile%\Application Data" /s /COPY:DAT /r:1 /w:1 /np /xo /eta

robocopy "c:\documents and settings\yourname\AppData\microsoft\outlook" "yourdestination" *.* /s /COPY:DAT /r:1 /w:1 /np /xo /eta

robocopy "c:\documents and settings\yourname\AppData\microsoft\signatures" "yourdestination" *.* /s /COPY:DAT /r:1 /w:1 /np /xo /eta

I think just do a robocopy /? and look at all of your options.

Report •

March 25, 2011 at 03:39:11
Thanks, yea as I was searching I came across Robocopy. Since I sometimes had to do 50+ profiles, I just opted to think backwards and add a long list of exclusions. Still beats the other ways we were doing.
Unfortunately it was an older Robocopy so I didnt know about the transferring of ownership flags, but I saw that now as well and will adjust it.
Only other thing I came across is some of these workstations were still on Fat32 so it cant copy stuff like that.
So far we put everything into a folder Backup in the root and just assign everyone full control.
I can then copy all the users info to their folders but then I'm the owner. I have to then add the user to each user folder and give full control

Can "C:\Documents and Settings\%userprofile%\" be used as the source? Wouldnt that just backup the logged in user?
Would "C:\Documents and Settings\*\Desktop" work?

Report •

March 25, 2011 at 08:07:27
"Only other thing I came across is some of these workstations were still on Fat32 so it cant copy stuff like that."

That is because FAT32 does not have NTFS security. The files ave attributes but it is not the same as user security.

"Can "C:\Documents and Settings\%userprofile%\" be used as the source? Wouldnt that just backup the logged in user?"

Oops sorry. I copied the code and modified it from my LOGOFF scripts. We do not use roaming profiles for the reasons you described in this post and just run backup scripts when the user logs off. Yes you will need to modify this. I was just only posting an example. I would write a BAT script to do this so you can use variables for each user or better yet you can use a for loop to loop through all users under the documents and settings like...

@echo off
set Destination = "d:\yourbackup"

for /f "tokens=*" %%a in ('dir "c:\documents and settings" /ad /b') do (
robocopy "%%a\AppData\microsoft\signatures" %Destination% *.* /s /COPY:DAT /r:1 /w:1 /np /xo /eta

Hope it helps.

Report •

Related Solutions

March 25, 2011 at 09:19:45
If you knew how much of a newbie I am to this, you'd cry hard.
I'll need to research that for and tokens to get an understanding of how it works.

But heres an idea of what I was attempting
Robocopy "C:\Documents and Settings\*\Desktop" "C:\%computername%-test.back\Documents and settings\*\Desktop" /s /COPYALL /ETA /r:1 /w:1 /XF "*.tmp" /XD "C:\Documents and settings\All Users" *temp *"temporary internet files" *cache

Id love to know more about that looping bit.
So then if Im correct Id need 1 execution of Robocopy per folder, desktop, documents, etc...
Also what would the syntax be to omit a folder like Administrator without the absolute path?
I tried \Administrator\, \Administrator, and Administrator\, and none seemed to work. Adminstrator alone worked but then I'm wondering if any user for whatever reason had a sub folder under Documents, that would be omitted too, correct?
Hmm on that note, best to absolute path i guess..

ok I got it somewhat working, heres what Im putting
for /f "tokens=*" %%a in ('dir "c:\documents and settings" /ad /b') do (
robocopy "C:\Documents and Settings\%%a\Favorites" "C:\%computername%-test\Documents and Settings\%%a\pew" /s /COPYALL /ETA /r:1 /w:1 /XF "*.tmp" /XD "C:\Documents and settings\All Users" *temp *"temporary internet files" *cache "All Users"
When i tried using destination, I had problems. Also for the destination, I tried just ....Documents and Settings\%%a\"
and it wouldnt process anything.
I tried Documents and Settings\%%a and it would just copy everything to doc and settings, no user names made.
Then I noticed it seems to ignore the last specified dir, so I put Documents and Settings\%%a\pew" and now everything outputs to Docs n settings\users\favorites
I noticed all the user folders it creates have me as owner, yet the favs inside will be correct with owner...
Im guessing its a side effect of that /pew

ok looks like just the favorites whacks out on me like the, Desktop seems to work fine.
however I guess its a side effect of using the %%a but I cant exclude a folder for the life of me. its username rbrigmon, Ive tried to exclude everything I can think of
C:\Documents and Settings\rbrigmon\
C:\Documents and Settings\rbrigmon\Desktop\
rbrigmon, \rbrigmon\, etc. Always goes through. Same as that all users

Report •

March 25, 2011 at 12:46:31
Unfortunately all the scripts I gave you where off the top of my head copied and pasted from other scripts I made for my self. I don't have time to write and test a complete script that will do every thing you want just give you samples so you know where to start. This site should help you some more with how to use a FOR loop...

Report •

March 25, 2011 at 16:41:06
No, that was great.
I'm pretty good if you throw a couple of loose bones my way.
So far its working fine I just cant seem to put exceptions on specific users, other than that its great.
Funny to see it say
Exclude: C:\Documents and Settings\rbrigmon\Desktop\
Backing up: C:\Documents and Settings\rbrigmon\Desktop\

Report •

Ask Question