Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

scripting a file/folder copy on windows server

Posted on 2011-03-10
2
Medium Priority
?
308 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 2000 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
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…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

824 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