Ok here is the scenario. I am trying to figure out a way to copy users' docs and settings (Favorites, My Documents and Desktop) to a network location as a backup for decommissioned drives. My problem is the variable of the user names %username%
is only the logged in user so I have opted to export to a list but I do not know the correct way to import those names back in or create the loop. Notice I also would like my destination directory to use the same username. Please notice this is just for the desktop folder so far. Here is what I have so far:
@echo off
md "\\server\share\folder\Downloads\%computername%"
cd documents and settings
dir >> list.txt
xcopy /s "c:\Documents and Settings\dir >> list.txt\Desktop" "\\server\share\folder\downloads\%computername%\(name from list)" /D/R
Answer
why don't you loop over your users dirs with something like this?
@echo off
md "\\server\share\folder\Downloads\%computername%"
cd documents and settings
for /f %%u in ('dir /b') do (
xcopy /s "c:\Documents and Settings\%%u\Desktop" "\\server\share\folder\downloads\%computername%\%%u" /D/R
IMHO no need to use a temp file... (unless you need it for another reason)
No comments:
Post a Comment