Download files from a FTP server using Ruby

10 Dec 2012

I think the last time I had to use FTP was around 2005, when I was playing with PHP and “all the cool stuff”. But today I had to use Ruby to access a FTP server and automate some tasks.

Ruby makes this task really easy and fast. Here follow the snippet used to connect, iterate over a list of files and download them:, USERNAME, PASSWORD) do |ftp|
  files = ftp.chdir(DIRECTORY)
  ftp.nlst('hd-*.jpg').each do |file_name|
     ftp.getbinaryfile(file_name, destination)

Migrating from Ruby to Elixir

FREE e-mail course

By joining this free, 5-lesson course, you'll receive personalized & actionable lessons that cover:

  • Is Elixir the right choice?
  • Getting the team up to speed
  • How to start your first Elixir project
  • Delivering a successful project
  • Next steps