<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Download files from ftp in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/download-files-from-ftp/m-p/620833#M48345</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are correct. i changed line 17 to ftp.cwd(os.path.join(directory)) and works, thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Dec 2018 19:27:24 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2018-12-12T19:27:24Z</dc:date>
    <item>
      <title>Download files from ftp</title>
      <link>https://community.esri.com/t5/python-questions/download-files-from-ftp/m-p/620831#M48343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to download all the pdf's from an ftp. &lt;/P&gt;&lt;P&gt;I get the following error and from what i found the error means.&lt;/P&gt;&lt;P&gt;"The server does not support the functionality required to fulfill the request. This is the appropriate response when the server does not recognize the request method and is not capable of supporting it for any resource."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How else can one download from a ftp server?&lt;/P&gt;&lt;P&gt;I appreciate the help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import os
import os.path
from ftplib import FTP

directory = "\\blah" #location of folder on ftp
copy_files = "*.pdf" # This is the files i would like to copy from the ftp site

folder = "D:\\temp\\temp\\"

out_path = os.path.join(folder)

#FTP logon
ftp = FTP("ftp.blah.blah")
ftp.login("blah1", "blah2")

# navigate folder
ftp.cwd(os.path.join(directory, copy_files))
print "Changed to " + os.path.join(directory, copy_files)

#Now get a list of all files in the folder
filenames = ftp.nlst()
print filenames

#and loop through the filenames to download the files to your local 'folder'
for f in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp; with open(os.path.join(out_path, f), 'wb') as local_file:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ftp.retrbinary('RETR '+ f, local_file.write)

ftp.close()
print "closed ftp connection"
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Traceback (most recent call last):
&amp;nbsp; File "D:\GIS Folder\Python Scripts\downloadftp\downloadftp.py", line 17, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ftp.cwd(os.path.join(directory, copy_files))
&amp;nbsp; File "C:\Python27\ArcGIS10.6\lib\ftplib.py", line 574, in cwd
&amp;nbsp;&amp;nbsp;&amp;nbsp; return self.voidcmd(cmd)
&amp;nbsp; File "C:\Python27\ArcGIS10.6\lib\ftplib.py", line 256, in voidcmd
&amp;nbsp;&amp;nbsp;&amp;nbsp; return self.voidresp()
&amp;nbsp; File "C:\Python27\ArcGIS10.6\lib\ftplib.py", line 231, in voidresp
&amp;nbsp;&amp;nbsp;&amp;nbsp; resp = self.getresp()
&amp;nbsp; File "C:\Python27\ArcGIS10.6\lib\ftplib.py", line 226, in getresp
&amp;nbsp;&amp;nbsp;&amp;nbsp; raise error_perm, resp
error_perm: 501 Syntax error in parameters or arguments.&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:29:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/download-files-from-ftp/m-p/620831#M48343</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2021-12-12T02:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Download files from ftp</title>
      <link>https://community.esri.com/t5/python-questions/download-files-from-ftp/m-p/620832#M48344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems ftp.cwd() takes a directory as the parameter, not a file path.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2018 19:22:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/download-files-from-ftp/m-p/620832#M48344</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2018-12-12T19:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Download files from ftp</title>
      <link>https://community.esri.com/t5/python-questions/download-files-from-ftp/m-p/620833#M48345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are correct. i changed line 17 to ftp.cwd(os.path.join(directory)) and works, thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2018 19:27:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/download-files-from-ftp/m-p/620833#M48345</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2018-12-12T19:27:24Z</dc:date>
    </item>
  </channel>
</rss>

