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?
2 Answers
Try /is
which is "include same files". In my case, robocopy won't overwrite a file, but with this option, it will.
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?
-
Hi Neil ,Thanks for your answer. So,You mean to say that by default robocopy will overwrite the file if it is already there in the destination folder. May 8, 2013 at 12:02
-
-
-
1Certainly, though I'm not sure how it helps you: ss64.com/nt/robocopy-exit.html May 8, 2013 at 12:48
where robocopy
to find the robocopy executable and make sure the one you're using matches the operating system. IIRC, the older version of robocopy that used to be distributed with the resource kit is not fully compatible with later operating systems and that might be manifesting as a hang.