Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nasrulhazim/cfd5f01e3b261b09d54f721cc1a7c50d to your computer and use it in GitHub Desktop.
Save nasrulhazim/cfd5f01e3b261b09d54f721cc1a7c50d 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')`
@Dollysi
Copy link

Dollysi commented Nov 3, 2022

this is the code for downloading all files, what if i want to download in selected date range?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment