compare 2 files and copy source if different from destination - vbscript?

I'm working on Windows XP and I need to make a script that would compare 2 files (1 on a server and 1 on a client). Basically, I need my script to check if the file from the client is different from the server version and replace the client version if it finds a difference (in the file itself, not only the modification date).


As you suggest, you can skip the date check as that can be changed without the contents changing.

First check that the sizes are different. If so, that may be enough to conclude that they are different. This can have false positives too though depending on the types of files. For example a unicode text file may contain the exact same content as an ansi text file, but be encoded with two bytes per character. If it's a script, it would execute with exactly the same results, but be twice the size.

If the sizes are the same, they may still contain different bytes. The brute force test would be to load each file into a string and compare them for equality. If they are big files and you don't want to read them all into memory if not necessary, then read them line by line until you encounter a difference. That's assuming they are text files. If they aren't text files, you can do something similar by reading them in fixed size chunks and comparing those.

Another option would be to to run the "fc" file compare command on the two files and capture the result and do your update based on that.

Need Your Help

Am in mutating the state in this reducer?

redux immutability react-redux

I've been reading about different methods to avoid mutating the state. One of those methods is using spread operators (...) and one of the methods to avoid using is push. However in my reducer I ne...

Selecting k*k subarray from p*p*n array in Fortran

select multidimensional-array fortran extract

I have a ppn array in Fortran, and I want to extract k*k subarray from that bigger array. I tried like this, but not sure does it work: