Comparing dates of two files in DOS batch (Windows 2000)

  • Thread starter Thread starter BertieBigBollox
  • Start date Start date
B

BertieBigBollox

whats the easiest way to do this?

Basically, what I want to do is compare the dates of two files (call
them file1 and file2). If file2 has a more recent date than file1, then

file2 should overwrite file1.


The application we run has got a sort of scheduled jobs thing so we
will be using this. It can execute a dos batch file or any executable.
If its easily done in a dos batch file this would be easy I guess.
 
whats the easiest way to do this?

Basically, what I want to do is compare the dates of two files (call
them file1 and file2). If file2 has a more recent date than file1, then

file2 should overwrite file1.


The application we run has got a sort of scheduled jobs thing so we
will be using this. It can execute a dos batch file or any executable.
If its easily done in a dos batch file this would be easy I guess.


@echo off
xcopy "c:\file2.ext" "d:\file1.ext" /d /y
 
In said:
@echo off
xcopy "c:\file2.ext" "d:\file1.ext" /d /y

Other notes:
the obscure REPLACE.EXE command for some conditions
DIR /O:D if using a sensible Date format such as YYYY-MM-DD
may be useful in some conditions.
 
Back
Top