TransWikia.com

Robocopy - Is there anyway to copy upper & lower case file/folder renames?

Super User Asked by jtbrown3 on November 9, 2021

Is there a command-line option or any way to get Robocopy to detect case changes/renames in files or folders on Windows? For example, If I rename source file ‘example.txt’ to ‘Example.txt’, Robocopy does not detect this rename and the changes are ignored and the file is not copied to the destination directory. This now leaves the destination directory out of sync from the source. Any suggestions on how to address or work around this issue would be much appreciated!

2 Answers

Windows is not case sensitive, meaning that mixed cases are considered to be identical. If you mirror (with the /MIR option) it will treat "sourceExample.txt" and "destinationexample.txt" as "identical" files, and as you said, it will not get copied because there is no need to copy an "identical" file.

I agree with the person that said that this is a defect, however, robocopy employs a heuristic based on timestamp and file size, so robocopy is "supposed to be" defective, or at least, not perfect.

One way to deal with it is to go to the destination and delete the file and then re-run Robocopy.

Another way is to "help" Robocopy detect a change by changing the timestamp or file-size of the file in the source. Changing the file content without altering the file-size and backdating the timestamp is probably not going to represent a change as far as Robobopy is concerned.

Lastly you might want to run cygwin "diff" in order to verify the work of robocopy. However, this verification itself is not perfect because cygwin is case-sensitive so instead of doing a comparison of files "example.txt" and "Example.txt" it will report that one is missing from the source and the other is missing from the destination. However, for the vast majority of files where this capitalization discrepancy is not happening, cygwin "diff" does serve to verify robocopy.

If you are not familiar with cygwin the only thing you need to know in order to do the diff is that C: drive is written as /cygdrive/c and D: drive is written as /cygdrive/d and just like in Linux and Unix the slash character is the separator. That is unlike Windows where the backslash is the separator.

Suppose for example, an original tree of "Documents" is on C: drive and a backup is on D: drive, the following cygwin command would verify the backup. (Adjust the paths to suit.)

diff --recursive --brief /cygdrive/c/users/userName/Documents /cygdrive/d/windowsbackup/Documents

Answered by H2ONaCl on November 9, 2021

Robocopy has a ' list only' command, also a verbose command, robocopy syntaxso the list only command could generate output of list of those files not copied (because robocopy deems them identical ) which you could massage in a spreadsheet to produce an input file allowing you to delete the problem files in the target directory, and then of course robocopy could copy them. Unfortunately you have not provided any detail of the scope of the task, so this note must fall short of a bells and whistles solution. Its the kind of task which can be done by scripting, but you have to decide whether the time debugging would be worth it.

Answered by pingpongpaddy on November 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP