How does Robocopy determine if a file is "changed"?

17

4

I'm looking here for detailed info about how the algorithm of Robocopy determines whether a file has changed or not. If I use for example the /mir parameter, Robocopy must determine which files are changed and which not. Does it use the modified timestamp or file sizes, hashes a combination of all?

Interestingly, it says nothing about it in the documentation.

user54512

Posted 2014-08-01T09:29:11.350

Reputation: 615

Answers

25

O.k. after spending the day researching this, reading the documentation, and testing for myself (all with the same result), I have the answer.

A short answer is: the default value of Robocopy is (unless you specify something different via parameters) that it will copy any file where the Timestamp OR the file size differs. Remember Robocopy ALWAYS copies from Source to Destination. So if you have a newer AND larger file in the destination, Robocopy will overwrite it with the older and smaller file from source (that's why I put emphasis on the word "differs" - it's not newer or larger, just different).

On a deeper level, you can check with the /it option even if attributes of a file differ and copy those that differ also - even if filesize and Timestamp are the same (O.K., for a 100%, I don't know if it will copy the file or only the missing attributes, but since the files are identical, the result will be the same).

I found the lengthy documentation which was quoted in the other thread - it is about the version XP010 (I guess it was Windows XP). But there is simply no newer documentation for robocopy. You can find the documentation here:

http://theether.net/download/Microsoft/Utilities/robocopy.pdf (Read the section "Using Robocopy File Classes", everything is laid out pretty precise there)

The documentation is about an older version of Robocopy (Under Win7 you usually have Version XP027) - but you can check for changes of the version on this site - which has a very neat overview:

http://yarcgui.wilkes.es/De/RoboCopy/index.htm

The bottom line is that there are not much differences between even XP and Win7 - only minor ones and the changes were to add parameters - not to alter them (with exception of the parameter /mir). And I think it's safe to say the mechanism of comparison won't have changed - since this would be a huge thing compared to the very small change of adding some more parameters.

This is probably the reason that there is no new documentation.

Hope that helps if you are looking for the same info and are reading this. I tried to be precise and did my research with care.

user54512

Posted 2014-08-01T09:29:11.350

Reputation: 615

2Does it use the created, modified, or both timestamps? – user643011 – 2018-04-15T15:29:20.470

@user54512 I don't understand at all.. so does it use timestamps or hashes? – Shayan – 2019-09-27T13:11:13.733

1@shayan: its written there, if Timestamp OR Filesize differs it will copy from source to destination. No hashes. Rest is in the documentation i put in the link. – user54512 – 2019-09-27T17:13:37.733