# Automating Image Downloads from a GitHub Repository with Ruby and Rails

DevFeed: [Automating Image Downloads from a GitHub Repository with Ruby and Rails](<https://devfeed.tech/articles/programming-rule-number-0-never-ever-work-too-hard-28314.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/ruby/2020/06/08/programming-rule-number-0-never-ever-work-too-hard.html>)

Author: Fuzzygroup

Published: 2020-06-08T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Programming](<https://devfeed.tech/topics/programming.md>), [Code](<https://devfeed.tech/topics/code.md>), [Rails](<https://devfeed.tech/topics/rails.md>), [GitHub](<https://devfeed.tech/topics/github.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [coding](<https://devfeed.tech/tags/coding.md>), [github](<https://devfeed.tech/tags/github.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rails](<https://devfeed.tech/tags/rails.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [wget](<https://devfeed.tech/tags/wget.md>)

## AI overview

The article explains how to automate downloading a set of images from a GitHub repository using Ruby code, a list of filenames, wget, and the Rails console. It argues that automating repetitive manual work can save time.

## Source excerpt

One of the better lessons that you learn as a programmer is that you never want to work too large, in short, that laziness can be a virtue. I'm speaking, of course, of doing things manually that you can automate. I recently wanted to download a set of images from github that represented anonymous animals. Here's the repo: [https://github.com/wayou/anonymous-animals/tree/master/icons](https://github.com/wayou/anonymous-animals/tree/master/icons) What I needed to automate downloading these was two things: A set of filenames A means to iterate them and fetch the data The set of filenames I got just by copying text from the github page and using a text editor macro to reduce it to a set of filenames that %w could easily make into an array. Here's the code for that: def self.animals anims = %w( Alligator.png Anteater.png Armadillo.png Auroch.png Axolotl.png Badger.png) end My routine to download these looks like this: def self.wgets AnonAnimalCommon.animals.each do |animal| `cd /Users/sjohnson/Sync/coding/rails/wipmarks/app/assets/images && wget wget https://raw.githubusercontent.com/wayou/anonymous-animals/master/icons/#{animal}` end end My final step was to call this routine from the Rails console (the entire class is called AnonAnimal): AnonAnimal.wgets Downloading all of these manually would have been likely about a half hour. Writing this code took maybe 10 minutes. Laziness for the win!