1

I want a batch file that will compare the last-modify date of two different files located in two different folders. If the local file is older than the server file, I want to overwrite the local file.

All I've found yet it a comparing the files with the dir command, which only works when both files are in the same folder (eg. dir /b /OD file1.txt file2.txt).

This is what I got actually, just need to add the comparison:

set "source=\\server\myApp.otm"
set "target=%userprofile%\Application Data\myApp\"

copy /Y /B "%source%" "%target%"
start outlook.exe /altvba "%target%\myApp.otm"

As you can see, the batch file is here to start Outlook with the VBA *OTM* file in parameter. I don't want to copy the 10MB file from the server each time if it isn't needed, thus the need for a comparison of last-modify dates (filesize would be okay too I guess).

dan
  • 3,439
  • 17
  • 54
  • 82

1 Answers1

1

try xcopy /d \\server\myapp.otm %userprofile%\... it will copy the server file only if it is newer than the local file

Loïc MICHEL
  • 24,935
  • 9
  • 74
  • 103
  • Wow, this just works like a charm. I changed `copy /Y /B` for `xcopy /Y /D` and it's all right. Thank you very much, didn't think it would be that easy. – dan Feb 04 '13 at 18:34