title: How to skip files being used in another program?
body: <p>I am making program to clear temp folders in windows at a specific time everyday.
  When ever i run it, I get this error. <a href="https://i.stack.imgur.com/EWbcy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EWbcy.png" alt="enter image description here" /></a>
  How do I fix it?</p>
  <pre><code>import schedule
  import os
  
  def job():
      path = &quot;C:/Windows/Temp/&quot;
      path2 = &quot;C:/Users/DANT~1/AppData/Local/Temp&quot;
      for file_name in os.listdir(path):
          file = path + file_name
          if os.path.isfile(file):
              os.remove(file)
      print(&quot;Done emptying temp folder&quot;)
  
      for file_name2 in os.listdir(path2):
          file2 = path2 + file_name2
          if os.path.isfile(file2):
              os.remove(file2)
      print(&quot;Done emptying temp folder&quot;)
  
  
  schedule.every().day.at(&quot;19:00&quot;).do(job)
  
  while True:
      schedule.run_pending()
  </code></pre>