title: Search for and replace text within text file using batch script
body: <p>I have recently taken on a daily task, where an existing .bat file creates the required network folders when run everyday... as part of the task, I am looking at amending the contents of a text file as part of the initial setup i.e. running the .bat file.</p>
  
  <p>Below is an extract of the .bat file, which has assigned the day, month and year as needed e.g. 11-03-2019, and creates the relevant folders the task needs, and copies across a control file (Filename2) to the newly created folder. What I'm looking to do is replace text within Filename2 in addition to having the folders created.</p>
  
  <pre class="lang-sh prettyprint-override"><code>set vb=%temp%\newdate.vbs
  echo Newdate = (Date()+0) &gt; %vb%
  echo Yyyy = DatePart("YYYY", Newdate) &gt;&gt; %vb%
  echo   Mm = DatePart("M"   , Newdate) &gt;&gt; %vb%
  echo   Dd = DatePart("D"   , Newdate) &gt;&gt; %vb%
  echo   Wd = DatePart("WW"  , Newdate) &gt;&gt; %vb%
  echo   Wn = DatePart("Y"   , Newdate) &gt;&gt; %vb%
  echo   Ww = datepart("W"   , Newdate) &gt;&gt; %vb%
  
  echo Wscript.Echo Yyyy^&amp;" "^&amp;Mm^&amp;" "^&amp;Dd^&amp;" "^&amp;Wd^&amp;" "^&amp;Ww^&amp;" "^&amp;Wn &gt;&gt; %vb%
  
  FOR /F "tokens=1-6 delims= " %%A in ('cscript //nologo %vb%') do (
          set Year=%%A
          set Month=%%B
          set Day=%%C
          set Week#=%%D
          set Weekday#=%%E
          set Day#=%%F
              )
  del %vb%
  
  for /f "Tokens=%Month%" %%A in (
    "January February March April May June July August September October November December") do (
    set Alfamonth=%%A
  )
  
  If %Month% lss 10 set Month=0%Month%
  if %Day% lss 10 set Day=0%Day%
  set Today=%Day%%Month%%Year%
  set Tomorrow=%Today%+1
  
  
  set Filename="path"
  echo Source path\
  echo filename = %Filename%
  echo.
  echo Today = %Today%
  echo Year =  %Year%
  echo Alpha month = %Alfamonth%
  echo Day=%Day%
  echo Month=%Month%
  
  md %FileName%\%Year%\%Alfamonth%" "%Year%\Client\%Day%-%Month%-%Year%
  
  ::Copy CONTROL FILE
  
  set Filename2="path\Client\Client.ini"
  copy %Filename2% %FileName%\%Year%\%Alfamonth%" "%Year%\Client\%Day%-%Month%-%Year%\"Raw Data"\"%Day%%Month%%Year%.ini"
  </code></pre>
  
  <p>There are 2 lines on the control file that I'm looking to amend:</p>
  
  <pre><code>directory=/dataload/fulfill/data/Client_Feb2018/02022018/
  
  filename=Client_01022018
  </code></pre>
  
  <p>For directory, I need to change <code>MonYYYY</code> and <code>DDMMYYYY</code> parts as follows every day e.g. <code>/dataload/fulfill/data/Client_Mar2019/11032019/</code>.
  The filename line needs the same change e.g. <code>Client_01022018</code> to <code>Client_11032019</code>.
  Given that <code>%Day%</code>, <code>%Month%</code> and <code>%Year%</code> have already been assigned, I'm hoping this will be an easy piece to add - any assistance is greatly appreciated!</p>
  
  <p>p.s. I'm completely new to batch scripting.</p>