none
scripting robocopy to copy many directories from one location to another

    Question

  • Hi,

    I have a server with 1000+ home directories.  I need to copy a subset (around 200) of those home directories from the server to another location.  I'm trying to script this using robocopy, but I'm not having much luck. 

    I already know the robocopy syntax I need to use.  I just need direction on how to point the robocopy script at a text file with all the directory names so I can loop through the same syntax 200+ times.

    All of the power shell and VB script examples I've found assume you're copying one large directory or a small number of directories.  I can't find anything that fits this issue.

    Any suggestions would be greatly appreciated.

    many thanks,

    elise

    Tuesday, December 27, 2011 11:23 PM

Answers

  • Try this little batch file:

    @echo off
    for /F "delims=" %%a in (folders.txt) do echo robocopy "d:\%%a" "\\Target\Share\%%a"  /s

    where folders.txt contains lines such as

    User Files\Financial
    Admin\Update Folders

    Since robocopy is a console command, I don't see much point in invoking it from a VB Script or a PowerShell file. It seems to add an unnecessary level of complexity, especially when dealing with double quotes.

    Remove the word "echo" in line 2 to activate the batch file.


    Wednesday, December 28, 2011 12:03 AM

All replies

  • This question should be answered in one of the many Robocopy forums.  Robocopy switches are not considered scripting.

     You might start here: http://social.technet.microsoft.com/Forums/en-AU/winserverManagement/threads

     

     


    jv
    • Edited by jrv Tuesday, December 27, 2011 11:44 PM
    Tuesday, December 27, 2011 11:41 PM
  • Try this little batch file:

    @echo off
    for /F "delims=" %%a in (folders.txt) do echo robocopy "d:\%%a" "\\Target\Share\%%a"  /s

    where folders.txt contains lines such as

    User Files\Financial
    Admin\Update Folders

    Since robocopy is a console command, I don't see much point in invoking it from a VB Script or a PowerShell file. It seems to add an unnecessary level of complexity, especially when dealing with double quotes.

    Remove the word "echo" in line 2 to activate the batch file.


    Wednesday, December 28, 2011 12:03 AM
  • If you are just going to use abatch fiole to feed a set of folders into robocopy then you might as well just use copy of xcopy.

    Use this in RoboCopy:  /XD dir [dir] to copy a list of folders to a single target.

    You can also stage a list of the folders to copy from a share.  Once you have created teh folders you want to keep an updated copy of, you can use MIR or Backup in RoboCopy to updated teh folders with only the changes.

    I suggested going tothe management forumbecause theer are many heavy RoboCOpy users who can work with someone to get thee correct setup. In nearly all cases there is never aneed to use a script or batch. 

    Robocopy has been designed to eliminate scripts and batch files.  Thge /SAVE:jobfile switch will save a command to a job file.  It can then be rerun without specifying any switches by just typing robocopy /JOB:jobfile.

    The Robocopy GUI is very helpfule at building comamndline so you don't have to worry about breaking teh edit or editing a batch filke.  Just select teh opstions and choose save to script.  TRhe rest ois automatic.

    This task is a perfect match for RoboCopy. Any other method would require some pretty difficult to test scripting unles you jsut want to copy every file everytime.  This could be very time consuming.  Robocopy can check every n miinutes and or n changes for new file changes and copy only what has changed.

     

     

     


    jv
    Wednesday, December 28, 2011 1:13 AM