{"id":9125,"date":"2021-11-30T23:19:02","date_gmt":"2021-11-30T23:19:02","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=9125"},"modified":"2021-11-30T23:19:46","modified_gmt":"2021-11-30T23:19:46","slug":"solved-continue-with-next-file-in-a-for-loop","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/continue-with-next-file-in-a-forloop\/27407.html","title":{"rendered":"Solved Continue With Next File In a For-Loop"},"content":{"rendered":"<p>Hi.<\/p>\n<p>I have a folder containing several q_*.sos files.<\/p>\n<p>In my program 3Q2PG.bat, I have a for-loop<\/p>\n<pre>...\r\nfor %%f in (%FILKATALOG%\\q_*.sos) do (\r\n...\r\n)<\/pre>\n<p>Within this for-loop a textfile &#8220;feil_koordsys.txt&#8221; may be created (depending on if something is wrong in the particular q_*.sos-file).<br \/>\nIf <b>nothing<\/b> is wrong, feil_koordsys.txt will <b>not<\/b> be created, and the rest of the loop should be carried out before continuing with the next q_*.sos file.<br \/>\nIf soemthing is wrong, feil_koordsys.txt will be created, and the rest of the commands in the for-loop should be skipped and the program should begin on the top of the loop with the next q_*.sos file in the folder.<\/p>\n<p>I have tried something like this:<\/p>\n<p>&nbsp;<\/p>\n<pre>echo off\r\nsetLocal enableDELAYedexpansion\r\n...\r\n&lt;b&gt;:loopen&lt;\/b&gt;\r\nfor %%f in (%FILKATALOG%\\q_*.sos) do (\r\n  ...\r\n    if exist %PROG_HOME%\\feil_koordsys.txt (\r\n    del %PROG_HOME%\\feil_koordsys.txt\r\n    call :loopen\r\n  )\r\n  ...\r\n)<\/pre>\n<p>This doesn&#8217;t work.<\/p>\n<p>Nor does this:<\/p>\n<pre>echo off\r\nsetLocal enableDELAYedexpansion\r\n...\r\nfor %%f in (%FILKATALOG%\\q_*.sos) do (\r\n&lt;b&gt;:loopen&lt;\/b&gt;\r\n  ...\r\n    if exist %PROG_HOME%\\feil_koordsys.txt (\r\n    del %PROG_HOME%\\feil_koordsys.txt\r\n    call :loopen\r\n  )\r\n  ...\r\n)<\/pre>\n<p>Does anyone know how to do this?<\/p>\n<p>I would appreciate any help.<br \/>\nThanks.<\/p>\n<p>Best regards<br \/>\nAnne, Norway<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":8},"question-category":[55],"question_tags":[],"class_list":["post-9125","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\/9125","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=9125"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=9125"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=9125"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=9125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}