title: How to delete files with a Python script from a FTP server which are older than 7 days?
body: <p>I would like to write a Python script which allows me to delete files from a FTP Server after they have reached a certain age. I prepared the scipt below but it throws the error message: <code>WindowsError: [Error 3] The system cannot find the path specified: '/test123/*.*'</code> </p>
  
  <p>Do someone have an idea how to resolve this issue? Thank you in advance!</p>
  
  <pre><code>import os, time
  from ftplib import FTP
  
  ftp = FTP('127.0.0.1')
  print "Automated FTP Maintainance"
  print 'Logging in.'
  ftp.login('admin', 'admin')
  
  # This is the directory that we want to go to
  path = 'test123'
  print 'Changing to:' + path
  ftp.cwd(path)
  files = ftp.retrlines('LIST')
  print 'List of Files:' + files 
  #--everything works fine until here!...
  
  #--The Logic which shall delete the files after the are 7 days old--
  now = time.time()
  for f in os.listdir(path):
    if os.stat(f).st_mtime &lt; now - 7 * 86400:
      if os.path.isfile(f):
          os.remove(os.path.join(path, f))
  except:
      exit ("Cannot delete files")
  
  print 'Closing FTP connection'
  ftp.close()
  </code></pre>