title: Batch File Loop Skip File if name contains
body: <p>I am creating this batch file, that works with handbrakecli, to batch convert avi to mp4.</p>
  
  <p>However I am stuck in how to continue the loop and skip the current file inside a loop.</p>
  
  <pre><code>FOR /R "%somepath%" %%G in (*.avi) DO (
  
  rem skip if filename contains word trailer
  
  rem skip if file name contains word sample
  
  rem do conversion
  )
  </code></pre>
  
  <p>This currently doesn't work in skipping the files that contain trailer or sample</p>
  
  <p>I have tried using find or findstr and both fail to skip. </p>
  
  <pre><code>    echo "%%G" | c:\windows\system32\findstr /i "trailer" &gt; NUL
      If %ERRORLEVEL% EQU 1 set skip Yes
  </code></pre>
  
  <p>Here is for sample.</p>
  
  <pre><code>    echo "%%G" | c:\windows\system32\findstr /i "sample" &gt; NUL
      If %ERRORLEVEL% EQU 1 set skip Yes
  </code></pre>
  
  <p>If a file contains either trailer or sample, I do not want to do any handbrakecli conversions, but to just skip it.</p>
  
  <p>I do echo's to display which files get converted, and it does include files with Sample or sample in the name.</p>
  
  <p>I have tried using find or findstr and both fail to set skip to yes</p>
  
  <p>if skip == No do ( rem do conversion )</p>
  
  <p>I only want to convert non-trailer/sample avi files. </p>
  
  <p>Thank you for your time.</p>