Skip to content

Instantly share code, notes, and snippets.

@Motoma
Created September 21, 2010 14:31
Show Gist options
  • Save Motoma/589759 to your computer and use it in GitHub Desktop.
Save Motoma/589759 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import ftplib
# Connection information
server = 'ftp.fu-berlin.de'
username = 'anonymous'
password = 'anything'
# Directory and matching information
directory = '/pub/misc/movies/database/'
filematch = '*.gz'
# Establish the connection
ftp = ftplib.FTP(server)
ftp.login(username, password)
# Change to the proper directory
ftp.cwd(directory)
# Loop through matching files and download each one individually
for filename in ftp.nlst(filematch):
fhandle = open(filename, 'wb')
print 'Getting ' + filename
ftp.retrbinary('RETR ' + filename, fhandle.write)
fhandle.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment