Skip to content

Instantly share code, notes, and snippets.

@jakelodwick
Created February 26, 2014 17:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakelodwick/9234495 to your computer and use it in GitHub Desktop.
Save jakelodwick/9234495 to your computer and use it in GitHub Desktop.
# This script assumes a dump of images from the Everyday iOS app.
# It distributes all images from images/ into N subdirectories,
# starting with 1 and proceeding to N.
# the intention is to load these images into a video editor
# to make a variant of Kalina's videos that shows multiple
# images at once.
require 'FileUtils'
print "Looking for images in folder 'images'... "
Dir.chdir("images")
images = Dir['*.jpg'].sort_by{ |f| File.mtime(f) }
puts "Found #{images.size}."
n = 3
c = 0
print "Copying into #{3} subfolders... "
images.each do |image|
c+=1
folder = (c % n + 1).to_s
Dir.mkdir(folder) if !Dir.exists?(folder)
FileUtils.copy_entry(image, "#{folder}/#{image}", true)
end
puts "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment