{"id":9829,"date":"2021-12-03T00:22:56","date_gmt":"2021-12-03T00:22:56","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=9829"},"modified":"2021-12-03T00:24:00","modified_gmt":"2021-12-03T00:24:00","slug":"batch-to-read-line-number-from-txt-file","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/windows-vista\/batch-to-read-line-number-from-txt-file\/6888.html","title":{"rendered":"Batch To Read Line Number From TXT File."},"content":{"rendered":"<p>Is it possible to read in specific lines from a batch file? In this example, I am trying to read the fourth line in the text file. I use an IF-ELSE statement with a GOTO statement to create a loop, but this code does not work. Any assistance is greatly appreciated.<\/p>\n<p>set \/a LineNumber = 4<br \/>\nset FileName = &#8220;c:\\mpsreports\\temp.txt&#8221;<br \/>\nset \/a counter = 0<\/p>\n<p>:loop<\/p>\n<p>echo %LineNumber%<br \/>\necho %counter%<br \/>\npause<br \/>\nif %LineNumber% == %counter% (<br \/>\nREM &#8211; read line for real<br \/>\nSET \/p MyLine=&lt;%FileName%<br \/>\ncls<br \/>\necho %MyLine% &gt;&gt; myline.txt<br \/>\npause<br \/>\ngoto :end<br \/>\n)else(<br \/>\nREM &#8211; read line and disregard<br \/>\nSET \/p MyLine=&lt;%FileName%<br \/>\nset \/a counter=%counter%+1<br \/>\npause<br \/>\ngoto :loop<br \/>\n)<\/p>\n<p>:end<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":21},"question-category":[75],"question_tags":[],"class_list":["post-9829","question","type-question","status-publish","hentry","question-category-windows-vista"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/9829","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=9829"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=9829"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=9829"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=9829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}