title: cmd for deleting files when name is not in a list but only when their folder doesn't have a string in its name
body: <p>I don't know much about cmd, but I have a folder X with a lot of subfolders and I need to create a cmd for deleting all the files in those subfolders but only:<br>
  - when file name is not in a like (<code>list.txt</code> -I've placed it in  folder <code>X</code>, but I can move it)<br>
  AND<br>
  - the folder that contains that file DOESN'T have a string (<code>2019</code>) in its name.</p>
  
  <p>In the file <code>list.txt</code> I have all the folder's path of the files (so something like <code>X/folder1/folder2/filename.jpg</code>).
  The files to be deleted are not only <code>.jpg</code>.</p>
  
  <p>Looking around I've tried:</p>
  
  <pre><code>@echo off
  
  setlocal enableextensions
  set "folder=C:\X"
  set "excludeFile=C:\X\list.txt"
  
  for /d %%a in ("%folder%\*") do (
  for /f "eol=: delims=" %%F in ('dir /b /a-d "%folder%" ^| findstr /vibg:"%excludeFile%"') do del "%folder%\%%F"
  )
  </code></pre>
  
  <p>but it doesn't work (and I don't know how to say to exclude folders with <code>2019</code> in their name).<br>
  Anyone can help?</p>
  
  <p>This is what's in <code>list.txt</code>:</p>
  
  <pre><code>1.pdf
  2.jpg
  3.jpg
  4.jpg
  5.pdf
  </code></pre>