title: Reading File Name using batch
body: <p>I'm working on a new project, and I would like some help. <br>
  I have a script that I put together and it works great, but would like to see if we can update it <br></p>
  <p>What I need help with is making the batch files read 2 parts of it's own file name and use that to match and replace content of many different .txt files <br></p>
  <p>these are my bat script names, I have made over 100 individual batch scripts <br></p>
  <pre><code>(50) Kentucky.bat
  (60) New_York.bat
  (90) Texas.bat
  </code></pre>
  <p>I have a total of 7 different .txt files and each txt files looks like this <br></p>
  <pre><code>cmmd.txt
     | Kentucky
     | New_York
     | Texas
     | Houston
  </code></pre>
  <p>This is how I setup my script, I'm ok with the setup, it does what it needs to <br></p>
  <pre><code>@echo off 
      setlocal enableextensions disabledelayedexpansion
  
      set &quot;search=Kentucky&quot;
      set &quot;replace=50&quot;
      
      set &quot;SOURCE=%~dp0New Folder 1&quot;
      
      set &quot;textFile1=cmmd.txt&quot;
      set &quot;textFile2=cwab.txt&quot;
      set &quot;textFile3=ecbc.txt&quot;
      set &quot;textFile4=elic.txt&quot;
      set &quot;textFile5=tcpd.txt&quot;
      set &quot;textFile6=uadu.txt&quot;
      set &quot;textFile7=urdm.txt&quot;
  
      for /f &quot;delims=&quot; %%i in ('type &quot;%source%\%textFile1%&quot; ^&amp; break ^&gt; &quot;%source%\%textFile1%&quot; ') do (
          set &quot;line=%%i&quot;
          setlocal enabledelayedexpansion
          &gt;&gt;&quot;%source%\%textFile1%&quot; echo(!line:%search%=%replace%!
          endlocal
      )
      
      for /f &quot;delims=&quot; %%i in ('type &quot;%source%\%textFile2%&quot; ^&amp; break ^&gt; &quot;%source%\%textFile2%&quot; ') do (
          set &quot;line=%%i&quot;
          setlocal enabledelayedexpansion
          &gt;&gt;&quot;%source%\%textFile2%&quot; echo(!line:%search%=%replace%!
          endlocal
      )
      
      for /f &quot;delims=&quot; %%i in ('type &quot;%source%\%textFile3%&quot; ^&amp; break ^&gt; &quot;%source%\%textFile3%&quot; ') do (
          set &quot;line=%%i&quot;
          setlocal enabledelayedexpansion
          &gt;&gt;&quot;%source%\%textFile3%&quot; echo(!line:%search%=%replace%!
          endlocal
      )
      
      for /f &quot;delims=&quot; %%i in ('type &quot;%source%\%textFile4%&quot; ^&amp; break ^&gt; &quot;%source%\%textFile4%&quot; ') do (
          set &quot;line=%%i&quot;
          setlocal enabledelayedexpansion
          &gt;&gt;&quot;%source%\%textFile4%&quot; echo(!line:%search%=%replace%!
          endlocal
      )
      
      for /f &quot;delims=&quot; %%i in ('type &quot;%source%\%textFile5%&quot; ^&amp; break ^&gt; &quot;%source%\%textFile5%&quot; ') do (
          set &quot;line=%%i&quot;
          setlocal enabledelayedexpansion
          &gt;&gt;&quot;%source%\%textFile5%&quot; echo(!line:%search%=%replace%!
          endlocal
      )
      
      for /f &quot;delims=&quot; %%i in ('type &quot;%source%\%textFile6%&quot; ^&amp; break ^&gt; &quot;%source%\%textFile6%&quot; ') do (
          set &quot;line=%%i&quot;
          setlocal enabledelayedexpansion
          &gt;&gt;&quot;%source%\%textFile6%&quot; echo(!line:%search%=%replace%!
          endlocal
      )
      
      for /f &quot;delims=&quot; %%i in ('type &quot;%source%\%textFile7%&quot; ^&amp; break ^&gt; &quot;%source%\%textFile7%&quot; ') do (
          set &quot;line=%%i&quot;
          setlocal enabledelayedexpansion
          &gt;&gt;&quot;%source%\%textFile7%&quot; echo(!line:%search%=%replace%!
          endlocal
      )
      
      call &quot;%~dp0\(60) New_York.bat&quot;
  </code></pre>
  <p>So this will be the end results after I run the first .bat and it calls the rest <br></p>
  <pre><code>cmmd.txt
     | 50
     | 60
     | 90
     | Houston
  </code></pre>
  <p>So I would like is to set this up where <code>set &quot;search=Kentucky&quot;</code> and <code>set &quot;replace=50&quot;</code> are setup by using the file name of the .bat file instead of me editing each <code>Search</code> and <code>Replace</code> <br></p>
  <p>If you noticed that I added a <code>call</code> at the end and it works great, but is there a way for a script to call the next .bat file without me having to edit each .bat file <br></p>
  <p>as you can see, I named my files by numeric order, and each .bat will call the next .bat file <br></p>
  <pre><code>(50) Kentucky.bat - this will call (60) New_York.bat
  (60) New_York.bat - this will call (90) Texas.bat
  (90) Texas.bat - the last one will not have a call
  </code></pre>
  <p>Having something like that will help save so much time, since all I would have to do is rename the .bat files as I need them, and that's it <br></p>
  <p>I do appreciate any help and for all your time <br></p>
  <p>meanwhile I will continue to make my .bat files <br></p>