{"id":6443,"date":"2021-11-19T08:09:05","date_gmt":"2021-11-19T08:09:05","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=6443"},"modified":"2021-11-19T08:09:32","modified_gmt":"2021-11-19T08:09:32","slug":"problem-converting-12-hr-to-24-hr","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/problem-converting-12hr-to-24hr\/26799.html","title":{"rendered":"Problem Converting 12-Hr To 24-Hr"},"content":{"rendered":"<p>I&#8217;m trying to determine if files written to a buffer directory are less than 5KB. My problem lies in that FORFILES outputs time in 12-hr format while echo&#8217;ing %time% outputs in 24-hr.<\/p>\n<p>This snippet is where I think I&#8217;m running into an issue. (I&#8217;m getting the Missing Operand error, and I can&#8217;t see where I&#8217;m going wrong&#8230; maybe I just need another set of eyes.)<br \/>\n[code]if NOT %%a==12 (<br \/>\nif %%d==PM (set \/a hh=%%a+12) else (set \/a hh=%%a)<br \/>\n) else (set \/a hh=%%a)[\/code]<\/p>\n<p>This is the entire script.<br \/>\n[code]<br \/>\nREM Calls directory = %1<br \/>\nREM File size (bytes) = %2<br \/>\nREM Time check window (min) = %3<\/p>\n<p>forfiles \/p %1 \/m *.wav \/s \/d -0 \/c &#8220;cmd \/c echo @fsize @ftime @fname&#8221; &gt;&gt; FSizes<\/p>\n<p>echo ; &gt; Problems<\/p>\n<p>REM FORFILES adds an empty line at beginning of file. Remove it.<br \/>\nmore +1 FSizes &gt; FSizes2<\/p>\n<p>for \/f &#8220;tokens=1,2,3,4&#8221; %%i in (FSizes2) do (<br \/>\nREM Testing %%l<\/p>\n<p>echo %%j:%%k&gt; FileTimeRaw<br \/>\nfor \/f &#8220;tokens=1,2,3,4 delims=:&#8221; %%a in (FileTimeRaw) do (<br \/>\nif NOT %%a==12 (<br \/>\nif %%d==PM (set \/a hh=%%a+12) else (set \/a hh=%%a)<br \/>\n) else (set \/a hh=%%a)<br \/>\n)<br \/>\nset \/a mm=%%b<br \/>\nset filetime=%hh%%mm%<br \/>\n)<\/p>\n<p>set \/a timediff=%time:~0,2%%time:~3,2%-%filetime%<\/p>\n<p>REM File is too old<br \/>\nif NOT %timediff% GTR %3 (<\/p>\n<p>REM File is too big<br \/>\nif NOT %%i GTR %2 (<\/p>\n<p>REM File is from yesterday<br \/>\nif NOT %timediff% LSS 0 (<\/p>\n<p>echo SMALLFILE &gt;&gt; Problems<br \/>\n)<br \/>\n)<br \/>\n)<br \/>\n)<\/p>\n<p>set x=0<\/p>\n<p>for \/f &#8220;eol=;&#8221; %%i in (Problems) do set \/a x=%x%+1<\/p>\n<p>echo %x%<\/p>\n<p>:end<br \/>\n[\/code]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":1},"question-category":[55],"question_tags":[],"class_list":["post-6443","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\/6443","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\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=6443"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=6443"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=6443"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=6443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}