title: Python - Delete all files EXCEPT for
body: <p>I have a Python script and I'm trying to delete all files in this directory EXCEPT for the .csv file.  Getting syntax error on the "not" in this line:</p>
  
  <pre><code>for CleanUp not in glob.glob("c:\python\AIO*.*"):
  </code></pre>
  
  <p>If I remove the "not", it will delete the AIO.csv file, but I need to preserve that file and ONLY that file.  Not clear why it's not working.</p>
  
  <pre><code>import os
  import glob
  import time
  
  file_path = "c:\python\AIO.csv"
  while not os.path.exists(file_path):
      time.sleep(10)
  
  if os.path.isfile(file_path):
   #Verifies CSV file was created, then deletes unneeded files.
      for CleanUp not in glob.glob("c:\python\AIO*.*"):
          os.remove(CleanUp)
  </code></pre>