[ftputil] Newbie FTP question
Chad Moore
smap2d at gmail.com
Wed Nov 28 18:36:09 CET 2007
Hello all,
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.
- - - - Description - - - -
Log into FTP
If a folder with todays date exists, download the entire directory to a
local drectory
If it doesnt exist return "nothing ready today"
- - - - Error - - - -
ftputil.ftp_error.FTPIOError: 550 2007_11_28/: Not a regular file
- - - - Code - - - -
import ftputil
import os
import sys
from time import strftime
from nt import mkdir
localPath = "C:/Documents and Settings/USERNAME/My Documents/Downloads"
#ftp host, login and password
host = ftputil.FTPHost('ftp.host.com', 'user', 'pass')
#host.set_directory_format("unix")
#directories on the FTP site
filesToDownloadFolder = 'subfolder01/subfolder02'
host.chdir(filesToDownloadFolder)
#get todays date
todaysDate = strftime("%Y_%m_%d/")
##if folder exists, download it and send email notification. if not, send
email, "nothing ready for today"
host.download(todaysDate, localPath, 'b') # remote, local, binary mode
host.close()
Thanks,
Chad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/ftputil/attachments/20071128/6c289ff0/attachment.htm
More information about the ftputil
mailing list