title: Looking for two strings for file names in Batch
body: <p>This should be simple..  But, I am not getting it..</p>
  
  <pre><code>SETLOCAL ENABLEDELAYEDEXPANSION
  FOR /r "D:\12" %%X IN (*) DO (
      FOR /F %%G IN (%%~nxX) DO for %%P in (server.sams.log* server.tims.log*) do ECHO %%P
  )
  ENDLOCAL
  </code></pre>
  
  <p>So, what I am trying to look for are any files that contain sams or tims in the file name, but ignore any other file in the folder.</p>
  
  <p>And, yes I know I can do the following..</p>
  
  <pre><code>FOR /r "D:\12" %%X IN (server.sams* server.tims*) DO (...
  </code></pre>
  
  <p>but I have other file names I want to compare..</p>
  
  <p>I have also thought about doing a compare partial strings, but does not seem to work either..  Yes, it seems to work just sams or tims alone and I have tried to use various combinations of GEQ, LSS, etc. to no success.
  <a href="https://superuser.com/questions/541575/comparing-part-of-a-filename-in-a-windows-batch-file">https://superuser.com/questions/541575/comparing-part-of-a-filename-in-a-windows-batch-file</a></p>
  
  <p>Thanks.</p>