Robocopy /MOVE switch RRS feed

  • Question

  • Hi all,

    I have created a script to move home folders using Robocopy, on a Win 2008 R2 64bit server.  All our file servers are Win 2k8 R2 64bit.

    The approach I have to move them effectively is as follows:

    1)  Create \\FileServerB\ServerB$\User1 (this is the destination)
    2)  Set Permissions on the above folder
    3)  Run Robocopy \\FileServerA\ServerA$\User1 \\FileServerB\ServerB$\User1 /MIR /COPY:DATOU /MOVE /R:1 /W:1 /MT:128 /LOG+MyLog.log

    It does a pretty good job in copying the files and folders (and subfolders), however, while I assume the source folder will be deleted, it actually behaves like this:

    1)  If the source folder does not have subfolders, itself will be deleted after being copied.
    2)  If the source folder contains subfolders, only files will be deleted.  So in the end it leaves the original empty folder structure in the source.

    Is this the expected behaviour of the /MOVE switch??   I try not to add an RD \\FileServerA\ServerA$\User1 /s /q statement after that, in case if something goes wrong with that Robocopy instance, the source will not be deleted.

    So what is the correct syntax/approach to achieve a clean and "robust" move of folders?

    Thanks ahead.

    Monday, August 13, 2012 10:28 PM


All replies

  • Hi

    Yes, What you are seeing is a expected behavior. And its by design.

    Using Robocopy to Move Files and Folders

    Deleting Empty Folders


    If you found this post helpful, please give it a "Helpful" vote.
    If it answered your question, remember to mark it as an "Answer".
    This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing!

    Tuesday, August 14, 2012 6:07 AM
  • If I'm reading his blogs correctly, he is saying he was using the /MOV switch (move files) with an option for recursion, and so had to run a script afterwards to remove empty directories. He then said he found /MOVE, which made his cleanup script unnecessary, since /MOVE will move files and folders (again, needing to use the option to recurse).

    I am also seeing the same behavior as the OP - /MOVE is leaving some folders behind. It will delete folders that were already empty from the source. If a folder had contents, it will correctly move the file, but not delete the folder from source.

    Sunday, December 9, 2012 4:35 AM
  • After some playing around, /MOVE behaves as expected if the /mt flag is not used - using it will leave empty folders behind
    • Proposed as answer by scott.tnet Sunday, December 9, 2012 8:01 PM
    • Edited by scott.tnet Sunday, December 9, 2012 8:01 PM clarity
    Sunday, December 9, 2012 8:01 PM