Robocopy not copying files in subdirectories

3

0

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 /MIR

Any 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

InterLinked

Posted 2017-09-07T12:24:52.123

Reputation: 1 761

/mir switch includes /e and /purge so *Extra File is logged when a file is being deleted from destination, in your case - from H:\Files\1 folder. Your command looks good to me, it works for me anywa. I can't think of anything else than robocopy having no read access to the subfolders of your source, K:\ some folder. If you're using NTFS, check if all subfolders inherit permissions from source folder. If this is a network drive - check share read rights. – Kitet – 2017-09-07T12:42:47.103

@Kitet K:\ is a WebDav share. H:\ is a local network share on an in-house file server. I keep files in the WebDav share so I can access them outside of the building, but for complicated reasons, even though I can map K:, I need them to also be available on local network storage. Yes, I have permissions to everything and can do this graphically, but I do this at logon/logoff via script. – InterLinked – 2017-09-07T12:43:39.167

Answers

0

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 /MIR

this should be used instead:

xcopy "K:\Some Folder" "H:\Files\1" /c /s /e /y

I don't know why robocopy didn't work, but xcopy with these switches does what needs to be done, quickly and efficiently.

InterLinked

Posted 2017-09-07T12:24:52.123

Reputation: 1 761

2

"Xcopy has been deprecated under Vista and Windows 2008, this means that while still available now it might disappear in a future OS release. To ensure your scripts are 'future proof' use other tools (such as Robocopy) instead of xcopy. " according to https://ss64.com/nt/xcopy.html

– user75875 – 2018-03-17T15:43:16.623

1

There's a /S option in robocopy, too. Also a /E to force empty folders to copy as well.

/S : Copy Subfolders.
/E : Copy Subfolders, including Empty Subfolders.

Supposedly, /MIR implies /E, but I have not found this to be empirically true. You should include add the /E option explicitly.

Michael - Where's Clay Shirky

Posted 2017-09-07T12:24:52.123

Reputation: 491