Make robocopy handle file-rename operations properly RRS feed

  • Question

  • Unsure if this is the correct Forum, please move it if appropriate.

    I am trying to use robocopy to replicate files and file changes across two remote machines, by running the following command on both machines:

    robocopy D:\rc_dir \\ip_of_remote_machine\rc_dir *.* /COPYALL /E /R:1 /W:5 /XJ /IT /XO /V /MON:1 /MOT:1

    Actually it works just fine - with the exception that when I rename a file on one machine, robocopy doesn't seem to handle that event properly. I very soon get two files - one with the original filename and the second one with the new filename of the renamed file, with identical file contents (obviously, robocopy suddenly sees two files and after one complete round of file replication, I am left with two files).

    Is there a way to get robocopy to handle this correctly?

    Edit: Oh, and pretty much the same thing happens when I delete a file.
    • Edited by merendo_07 Tuesday, April 10, 2012 6:07 AM supplemental
    • Moved by Just Karl Thursday, June 5, 2014 7:13 PM Looking for the proper forum.
    Tuesday, April 10, 2012 5:49 AM


All replies

  • Robocopy doesn't know that a file was renamed. As you've observed, it sees a new file and a missing file.

    It looks like you are trying to keep two folders in synch with a continuously running robocopy instance. I was going to suggest Microsoft's SyncToy because it would track the changes (in a separate file) so it would capture rename events. But I don't believe it can be run continuously (maybe it can run using a scheduled task?) Might be worth looking into.

    Jason Warren
    Infrastructure Specialist
    Habañero Consulting Group

    Tuesday, April 17, 2012 9:06 PM
  • Jason, thank you for your response! It is correct, I am trying to keep two folders in bidirectional sync using Robocopy. Actually, I even hope to keep several folders in sync (that is, one folder with one inventory, but across more than two machines). Each machine would start one instance of Robocopy for every other machine the file inventory is to be synced with, so there could be a great number of channels (k=n!/(n-2)!). Unfortunately, I want to integrate the tool into my own software and as SyncToy will display it's own GUI, it's not suitable for my application.

    Right now I'm planning to run Robocopy recurringly, and make such special changes (delete or rename files and folders) when Robocopy is not running.

    I hope this works. If anyone can spot potential flaws in this concept, please do let me know.

    Wednesday, April 18, 2012 9:03 AM
  • Hello,

    The Windows Desktop Perfmon and Diagnostic tools forum is to discuss performance monitor (perfmon), resource monitor (resmon), and task manager, focusing on HOW-TO, Errors/Problems, and usage scenarios.

    As the question is off topic here, I am moving it to the Where is the Forum... forum.


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    Thursday, June 5, 2014 7:12 PM
  • Might try them over here.

    Scripting forum on MSDN

    Scripting Guys forum on TechNet




    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    • Proposed as answer by Just Karl Friday, June 6, 2014 1:12 AM
    • Marked as answer by Just Karl Friday, June 13, 2014 8:24 PM
    Friday, June 6, 2014 1:05 AM