Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import pysftp
- import stat
- with pysftp.Connection('example.com', username='username', password='password') as sftp:
- sftp.cwd("/remote/path")
- for f in sftp.listdir_attr():
- if not stat.S_ISDIR(f.st_mode):
- print("Checking %s..." % f.filename)
- if ((not os.path.isfile(f.filename)) or
- (f.st_mtime > os.path.getmtime(f.filename))):
- print("Downloading %s..." % f.filename)
- sftp.get(f.filename, f.filename)
Add Comment
Please, Sign In to add comment