Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save duncangh/93b9cf32736eeeee323d0f2071441fbf to your computer and use it in GitHub Desktop.
Save duncangh/93b9cf32736eeeee323d0f2071441fbf to your computer and use it in GitHub Desktop.
Download Files From FTP Server using Python3
from ftplib import FTP
from datetime import datetime

start = datetime.now()
ftp = FTP('your-ftp-domain-or-ip')
ftp.login('your-username','your-password')

# Get All Files
files = ftp.nlst()

# Print out the files
for file in files:
	print("Downloading..." + file)
	ftp.retrbinary("RETR " + file ,open("download/to/your/directory/" + file, 'wb').write)

ftp.close()

end = datetime.now()
diff = end - start
print('All files downloaded for ' + str(diff.seconds) + 's')`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment