Needed: FTP Upload Directory Tree script

Stefan Schwarzer sschwarzer at sschwarzer.net
Sun Jun 10 16:56:10 EDT 2007


Hello Ian,

On 2007-06-10 10:01, IanC wrote:
> Does anyone know of a function or script to upload an entire
> subdirectory tree from a local file space to an FTP server?
> 
> The Python distribution comes with "ftpmirror.py", which performs
> a mirror download of a directory tree, but I need the "Upload"
> version of this.

I'm just working on an ftputil[1] extension[2] to copy/mirror
directory trees between local filesystems and remote FTP hosts.
It's in pre-alpha state (just in development), but maybe it
already does what you want. Did I note that this is an only
slightly tested module and might destroy your files? - That is,
use it at your own risk. I recommend you look at the source
code of ftp_sync.py before using it.

It works like this:

- Download[3] and install ftputil.

- Download the file[2] and put it into the site-packages/ftputil
  directory.

- Use the library like:

import ftputil
from ftputil import ftp_sync

source = ftp_sync.LocalHost()
target = ftputil.FTPHost(hostname, username, password)
syncer = ftp_sync.Syncer(source, target)
syncer.sync(source_directory, target_directory)

Note that the _contents_ of source_directory (_not_ the directory
itself) will be copied to the already-existing target_directory.

If you have further questions or feedback, please send e-mail
to the ftputil mailing list[4] or to me[5].

[1] http://ftputil.sschwarzer.net
[2] http://ftputil.sschwarzer.net/trac/browser/trunk/ftp_sync.py?format=txt
[3] http://ftputil.sschwarzer.net/trac/wiki/Download
[4] mailto:ftputil at codespeak.net
[5] mailto:sschwarzer at sschwarzer.net

Stefan



More information about the Python-list mailing list