{"id":10627,"date":"2021-12-06T09:01:15","date_gmt":"2021-12-06T09:01:15","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=10627"},"modified":"2021-12-06T09:01:41","modified_gmt":"2021-12-06T09:01:41","slug":"batch-file-to-set-variable-of-a-file-name","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/batch-file-to-set-variable-of-a-file-name\/23097.html","title":{"rendered":"Batch File To Set Variable Of a File Name"},"content":{"rendered":"<p>I&#8217;m try to make batch file that looks in the dir that it is running in looking for .xml. then take the file name of the XML and sets it as a variable for use finding the file that changes need to made to and to be used in the file its self.<\/p>\n<p>I&#8217;m use Change.com to change text in the XML file.<\/p>\n<p>But the way that I&#8217;m getting the file name dose not work if there is special chracters in the filename like a space.<\/p>\n<p>Here is a working version of what I have:<\/p>\n<p>@echo off<br \/>\nfor \/F %%a in (&#8216;dir \/b *.xml&#8217;) do set FileName=%%~na<\/p>\n<p>echo what file do you have %Filename%<br \/>\necho.<\/p>\n<p>pause<\/p>\n<p>echo lets make a file&#8230;.<\/p>\n<p>change.com %Filename%.xml &#8220;***FILE_NAME***&#8221; &#8220;%Filename%&#8221;<br \/>\necho.<br \/>\npause<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":10},"question-category":[55],"question_tags":[],"class_list":["post-10627","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\/10627","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=10627"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=10627"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=10627"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=10627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}