{"id":10086,"date":"2021-12-05T03:32:14","date_gmt":"2021-12-05T03:32:14","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=10086"},"modified":"2021-12-05T03:34:05","modified_gmt":"2021-12-05T03:34:05","slug":"solved-batch-file-to-extract-certain-text-from-a-txt-file","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/batch-file-to-extract-certain-text-from-a-txt-file\/28015.html","title":{"rendered":"Solved Batch File To Extract Certain Text From a Txt File"},"content":{"rendered":"<p>Hi,<\/p>\n<p>I am trying to write an automatic batch file that will extract 3 lines after a certain string.<\/p>\n<p>For example I have the a text file with the following information in it (this is just a portion of the text file),<\/p>\n<p>Forecast for the rest of Sunday 3 June<br \/>\nCloudy. Patchy morning fog. Isolated showers becoming scattered this afternoon.<br \/>\nWinds southeasterly and light tending east to southeasterly up to 25 km\/h<br \/>\nduring the morning.<\/p>\n<p>City Centre A few showers. Max 15<br \/>\nChance of any rainfall: 70%<br \/>\nRainfall: 2 to 4 mm<\/p>\n<p>Around Melbourne<br \/>\nGeelong Max 15 Watsonia Max 14<br \/>\nLaverton Max 15 Mount Dandenong Max 10<br \/>\nTullamarine Max 14 Yarra Glen Max 14<br \/>\nScoresby Max 14 Frankston Max 14<\/p>\n<p>No UV Alert, UV Index predicted to reach 2 [Low]<\/p>\n<p>Forecast for Monday 4 June<br \/>\nCloudy. Scattered showers. Winds south to southeasterly up to 35 km\/h.<\/p>\n<p>City Centre A few showers. Min 10 Max 14<\/p>\n<p>Forecast for Tuesday 5 June<br \/>\nPartly cloudy. Isolated showers clearing during the afternoon. Winds south to<br \/>\nsoutheasterly up to 30 km\/h.<\/p>\n<p>City Centre Shower or two clearing. Min 10 Max 14<\/p>\n<p>I want to run a batch file that will extract all information between the first &#8216;City Centre&#8217; and &#8216;Around Melbourne&#8217; into a new txt file. So in this example the new text file should read,<\/p>\n<p>A few showers. Max 15<br \/>\nChance of any rainfall: 70%<br \/>\nRainfall: 2 to 4 mm<\/p>\n<p>The problem is &#8216;City Centre&#8217; appears multiple times in the original text file, I only want to grab information from the first &#8216;City Centre&#8217; and end at &#8216;Around Melbourne&#8217;.<\/p>\n<p>Any help would be much appreciated.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":66},"question-category":[55],"question_tags":[],"class_list":["post-10086","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\/10086","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=10086"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=10086"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=10086"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=10086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}