title: FORFILES: Only delete file if RELPATH contains substring
body: <p>In another <a href="https://stackoverflow.com/questions/7005951/batch-file-find-if-substring-is-in-string-not-in-a-file">topic</a> I found the following code snippet to check if a string contains a substring.</p>
  
  <pre><code>if not x%str1:bcd=%==x%str1% echo It contains bcd
  </code></pre>
  
  <p>Now I am trying to implement this in my FORFILES method. FORFILES should delete XML files that are in a subfolder that contains the substring 'IMG'. I adapted the code as follows:</p>
  
  <pre><code>set loglocation=C:\Tools\PurgeOldFiles\log\DELETEOLD_XML_IMG.txt
  set olderthan=30
  set source=X:\Test
  set extension=XML
  
  FORFILES -p%source% -s -m*.%extension% -d-%olderthan% -c"CMD /C if not x@RELPATH:img=%==x@RELPATH DEL @PATH\@FILE /q &amp; echo @PATH\@FILE deleted." &gt;&gt; %loglocation%
  </code></pre>
  
  <p>It does not delete the old (older than 30 days) XML files in an IMG subfolder.</p>
  
  <p>I guess that I have some kind of (syntax) error in "x@RELPATH:img=%==x@RELPATH".</p>