{"id":12263,"date":"2021-12-09T01:14:44","date_gmt":"2021-12-09T01:14:44","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=12263"},"modified":"2021-12-09T01:15:02","modified_gmt":"2021-12-09T01:15:02","slug":"solved-comparing-two-file-dates-in-cmd","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/comparing-two-file-dates-in-cmd\/28059.html","title":{"rendered":"Solved Comparing Two File Dates In CMD"},"content":{"rendered":"<p>Hello all<\/p>\n<p>hope you can help.<\/p>\n<p>Using a batch file, I have recently been asked to compare two file dates in a particular folder. Lets say the files names are F1.txt and mail.log.<\/p>\n<p>If mail.log date is prior to F1.txt date then I want the batch file command to run another bat file, wait 20 seconds and then compare two other files within another folder&#8230;<\/p>\n<p>____________________________________<br \/>\nThe logics is like this:<\/p>\n<p>IF mail.log date &lt; F1.txt date in C:\\TEST1 then run Run.bat ELSE<br \/>\nWait 20 seconds<br \/>\nIF mail.log date &lt; F2.txt date in C:\\TEST2 then run Run.bat ELSE<br \/>\nWait 20 seconds&#8230;.<br \/>\n____________________________________<\/p>\n<p>There are about 10 of these folders.<br \/>\n-I also do not want to run the Run.bat if the file dates in that folder are the -same, only if the mail.log file less than the F. files<br \/>\n-I also want to remove the time portion of the date<\/p>\n<p>I have looked at some code like this:<\/p>\n<p>SET FILE1=mail.log<br \/>\nSET FILE2=F1.txt<br \/>\nFOR \/F %%i IN (&#8216;DIR \/B \/O:D %FILE1% %FILE2%&#8217;) DO SET NEWEST=%%i<br \/>\nECHO %NEWEST%<\/p>\n<p>but I cannot fit what I have together<br \/>\nPlease can someone help<\/p>\n<p>Thankyou<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":7},"question-category":[55],"question_tags":[],"class_list":["post-12263","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/12263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=12263"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=12263"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=12263"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=12263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}