title: Modify a string in a .properties file with batch
body: <p>I am trying to modify a certain property in my csm.properties by executing a script. 
  I looked up a lot and in the end, came to this code. </p>
  
  <pre><code>set "search=CLASSPATH"
  set "insert=CLASSPATH^=plugins^/Numbering.jar^\^:"
  
  set "textFile="%workingPlace%bin\csm.properties""
  
  FOR /f "delims=" %%i in ('type "%textFile%" ^&amp; break ^&gt; "%textFile%" ') do (
      FOR /f "tokens=1*delims==" %%g IN ("%%i") DO (
          IF /i "%%g" == %search% (
              set "line=%%i"
                  setlocal enabledelayedexpansion
                  &gt;&gt;"%textFile%" echo(!line:%search%=%insert%!
                  endlocal
          )ELSE (
          %%i
          )
      )
  )
  </code></pre>
  
  <p>This code should read every line in my file and use <code>=</code> as a delimiter. If the code gets "CLASSPATH" as property, that line should get modified.
  But it seems like CLASSPATH isn't found.</p>
  
  <p>This is how csm.properties looks like:</p>
  
  <pre><code>#Tue Jul 10 08:50:23 CEST 2018
  JAVA_ARGS=-Xmx20000M -DLOCALCONFIG\=true -splash\:data/splash.png -Dmd.class.path\=$java.class.path -Dcom.nomagic.osgi.config.dir\=configuration -Desi.system.config\=data/application.conf -Dlogback.configurationFile\=data/logback.xml -Dsun.locale.formatasdefault\=true -Dinitial.user.language\=de
  JAVA_HOME=jre1.8.0_152
  BOOT_CLASSPATH=lib/xalan.jar
  MAIN_CLASS=com.nomagic.osgi.launcher.ProductionFrameworkLauncher
  MAC_JAVA_ARGS="-Xdock\:name\=Cameo Systems Modeler" -Xdock\:icon\=bin/md.icns -Dapple.laf.useScreenMenuBar\=true
  APP_ARGS=
  DEFAULT_MEMORY_SETTINGS_64=-Xmx[30%,1200,4000]M
  DEFAULT_MEMORY_SETTINGS_32=-Xmx800M
  CLASSPATH=lib/patch.jar\:lib/brand_api.jar
  CONSOLE=false
  </code></pre>
  
  <p>After modifications, <code>CLASSPATH</code>should look like this:</p>
  
  <pre><code>CLASSPATH=plugins/Numbering.jar\:lib/patch.jar\:lib/brand_api.jar
  </code></pre>