0

I try to imitate in a Windows batch file the behavior of make:

if file.obj is-older-than file.c compile file.c

How to express this in a batch file? I only know

if not exist file.obj compile file.c

which is not the same.

EDIT: This question already has an answer: A similar question has been asked, with the best answer (in my view) being in a comment on this answer.

Alexander Gelbukh
  • 2,104
  • 17
  • 29
  • Yes, a similar question has been asked, but this is a specific case of that question, and the real answer is in a comment on one (and not the chosen one!) answer to that question, this one: https://stackoverflow.com/a/29505781/3814740. I suggest to keep the question, and this comment will direct the readers to the best answer. – Alexander Gelbukh Aug 08 '18 at 05:04
  • Here is a link that will explain: https://stackoverflow.com/questions/1687014/how-do-i-compare-timestamps-of-files-in-a-dos-batch-script – Kevin Bridges Aug 09 '18 at 22:09
  • The best answer there is buried in a comment to one of the answers. I copy it here: `xcopy /DYLR src "dst*" | findstr /BC:"0" >nul && @echo dst is newer`. – Alexander Gelbukh Aug 10 '18 at 04:14

0 Answers0