title: Downloading Files from FTP server which is updated in last n hours
body: <p>My requirement is to download the files which are arrived in the root directory in the last 24 hours.</p>
  <p>The code below is working in a subdirectory (let's say ftp.cwd(&quot;/Landing/&quot;) but trigger the error while I am changing to the root directory.</p>
  <pre><code>filematch='*.csv'
  ftp.cwd(&quot;/&quot;)
  for file_data in ftp.mlsd(filematch):
      file_name,meta = file_data
      last_modified = datetime.strptime(meta.get(&quot;modify&quot;), &quot;%Y%m%d%H%M%S&quot;)
      
      if (last_modified) &gt;= now- timedelta(hours=0, minutes=1440):                   
          print(last_modified)
          local_filename = os.path.join('C:\\Work\\', file_name)
          file = open(local_filename, 'wb')
          with open(local_filename, &quot;wb&quot;) as file:
              ftp.retrbinary(f&quot;RETR {file_name}&quot;, file.write)
  </code></pre>
  <p>If I'am changing the <code>&gt;=</code> to <code>==</code> then its working in root directory ( but both condition are fine in subdirectory; issue is only in root)</p>
  <p><code>if (last_modified) = now- timedelta(hours=0, minutes=1440):</code></p>
  <p><strong>Error Message:-</strong></p>
  <p>File &quot;C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\ftplib.py&quot;, line 425, in retrbinary    with self.transfercmd(cmd, rest) as conn:  File &quot;C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\ftplib.py&quot;, line 382, in transfercmd    return self.ntransfercmd(cmd, rest)[0]  File &quot;C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\ftplib.py&quot;, line 348, in ntransfercmd    resp = self.sendcmd(cmd)  File &quot;C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\ftplib.py&quot;, line 275, in sendcmd    return self.getresp()  File &quot;C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\ftplib.py&quot;, line 248, in getresp    raise error_perm(resp)<strong>ftplib.error_perm: 550 Permission denied.</strong></p>