<font size="2">Hello all,<br><br>I am wondering how to simply download an entire directory consisting of subdirectories and files. I am sure I can figure out how to "walk" through the directory structure, but isn't there an easier way to just suck down an entire direcotry from the FTP site? Here is my code and details.
<br><br>- - - - Description - - - -<br>Log into FTP<br>If a folder with todays date exists, download the entire directory to a local drectory<br>If it doesnt exist return "nothing ready today"<br><br>- - - - Error - - - -
<br>ftputil.ftp_error.FTPIOError: 550 2007_11_28/: Not a regular file<br><br>- - - - Code - - - - <br></font><p class="first"><font size="2"><tt class="literal"><span class="pre"><font size="4">import ftputil<br>import os
<br>import sys<br>from time import strftime<br>from nt import mkdir<br><br>localPath = "C:/Documents and Settings/USERNAME/My Documents/Downloads"<br><br>#ftp host, login and password<br>host = ftputil.FTPHost('
<a href="http://ftp.host.com">ftp.host.com</a>', 'user', 'pass')<br>#host.set_directory_format("unix")<br><br>#directories on the FTP site<br>filesToDownloadFolder = 'subfolder01/subfolder02'
<br>host.chdir(filesToDownloadFolder)<br><br>#get todays date<br>todaysDate = strftime("%Y_%m_%d/")<br>##if folder exists, download it and send email notification. if not, send email, "nothing ready for today"
<br><br>host.download(todaysDate, localPath, 'b') # remote, local, binary mode<br><br>host.close()<br></font><br></span><span class="pre"></span></tt></font></p><font size="2">Thanks,<br>Chad<br></font>