Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# 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'... "
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|
folder = (c % n + 1).to_s
Dir.mkdir(folder) if !Dir.exists?(folder)
FileUtils.copy_entry(image, "#{folder}/#{image}", true)
puts "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment