I am having problems with robocopy for whatever reason.
I have several scripts I use daily that utilize copy, xcopy, and robocopy, and they are all working currently, except for this one. I am using the same, standard switches I use in my other scripts.
robocopy "K:\Some Folder" "H:\Files\1" /e /w:0 /r:2 /MIRAny files directly in K:\Some Folder get copied. But any files in, say K:\Some Folder\Some Subfolder do not get copied. I looked this up and using either /s or /e should copy all files in sub-directories as well. Why isn't it? If I pause the script, it says "*Extra Files" in some places - that might have something to do with it.
Previously I was using these switches, but it still didn't work after simplifying:
/e /w:0 /r:2 /XO /NFL /NDL /NJH /NJS /nc /ns /np 2 3 Answers
There's a /S option in robocopy, too. Also a /E that is like /S, but additionally forces empty folders to be copied.
/S: Copy Subfolders.
/E: Copy Subfolders, including Empty Subfolders.
Supposedly, /MIR implies /E…
/MIR: MIRror a directory tree—equivalent to/PURGEplus all subfolders (/E)
…but I have not found this to be empirically true. You should include the /E or /S option explicitly.
I found that the /b (Backup mode) switch works for me. Even though it appeared that I had the proper permissions to copy, robocopy seemed to disagree. /b fixed that issue.
Problem: Any files directly in K:\Some Folder get copied. But any files in K:\Some Folder\Some Subfolder do not get copied.
The solution is to not use robocopy at all, but use xcopy.
Instead of:
robocopy "K:\Some Folder" "H:\Files\1" /e /w:0 /r:2 /MIRthis should be used instead:
xcopy "K:\Some Folder" "H:\Files\1" /c /s /e /yI don't know why robocopy didn't work, but xcopy with these switches does what needs to be done, quickly and efficiently.
1