Overwriting with robocopy
I am using robocopy to copy files, but it simply hangs (I guess the reason is that the file is already present in the location). Is there an option using which I can overwrite files (if they are already in the destination) or simply copy it if it is not there?
Solution 1:
Try /is
which is "include same files". In my case, robocopy won't overwrite a file, but with this option, it will.
Solution 2:
Robocopy will be able to overwrite files unless you tell it not to (using one of the /X*
switches). A locked file could hang it, but actually Robocopy will retry, with defaults that means it can take a long time retrying a file. You could change the retry options so that it only retries a couple of times and perhaps doesn't wait very long between retries.
From robocopy.exe /?
:
::
:: Retry Options :
::
/R:n :: number of Retries on failed copies: default 1 million.
/W:n :: Wait time between retries: default is 30 seconds.
/REG :: Save /R:n and /W:n in the Registry as default settings.
/TBD :: wait for sharenames To Be Defined (retry error 67).
Also, it's possible it's recursively copying data through junction points. I always use the /XJ
option in Robocopy operations to prevent this.
Questions as the devil's advocate:
- What command line are you using and can you give us the console output?
- Are you sure the files it's hanging on aren't just very big?
- Are you sure the files aren't locked?
- Are you running this interactive on the desktop? Could it be permissions-related?