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

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.
 
F

foxidrive

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
 
M

Mark V

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top