13

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?

4
  • 1
    What do you mean by hangs? Do you see an error or anything? PS look at the /mir option... May 8, 2013 at 11:29
  • It doesnot give any error. I can't use /mir option as it would delete the files already present in the destination folder.Please suggest some other options. May 8, 2013 at 11:38
  • Try 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. May 8, 2013 at 23:10
  • You can run it with /V option to show details what it does.
    – M-Razavi
    Aug 5, 2015 at 7:16

2 Answers 2

21

Try /is which is "include same files". In my case, robocopy won't overwrite a file, but with this option, it will.

7

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:

  1. What command line are you using and can you give us the console output?
  2. Are you sure the files it's hanging on aren't just very big?
  3. Are you sure the files aren't locked?
  4. Are you running this interactive on the desktop? Could it be permissions-related?
4
  • 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
  • It certainly should, yes. May 8, 2013 at 12:03
  • Can you please tell me what will be the exit code in that case? May 8, 2013 at 12:13
  • 1
    Certainly, though I'm not sure how it helps you: ss64.com/nt/robocopy-exit.html May 8, 2013 at 12:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .