Solved

scripting a file/folder copy on windows server

Posted on 2011-03-10
2
304 Views
Last Modified: 2012-05-11
Hi

I need help writing a script to copy a bunch of files.  I am trying to relocate users' my documents folders.

currently they are stored in this location:
"\\servername\username\" (each user is shared individually.  all username folders have the same "documents" label because of the desktop.ini file -very confusing)

i would like to move them all to:
"\\servername\sharename\username\my documents\"

so far i have this running as a loggoff script but it isnt ideal:
robocopy "\\servername\%username%" "\\servername\newshare\%username%\My documents" /mir /sec

what would be the best way to move the files directly on the server without using logon/off scripts?  

thanks for help
0
Comment
Question by:Luxtech
2 Comments
 
LVL 11

Accepted Solution

by:
Tasmant earned 500 total points
ID: 35094477
you could try something like this:
for /F "tokens=*" %i in ('dir /B /A:D') do xcopy "%i\Documents" "D:\newshare\%i\My Documents" /K
 /O /X /Y /E /H
this has to be run on the folder where are stored all the users folders (by example D:\Home)
you should test it before.
0
 
LVL 1

Author Closing Comment

by:Luxtech
ID: 35097416
the script worked in my test setup! not sure what all switches do though, but thanks
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question