Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script to consolidate all the .MOV files on my computer into a single directory, organized by YYYY/YYYY-MM/ dir structure.
require 'fileutils'
base_dir = ARGV[0]
target_dir = ARGV[1]
movies = Dir.glob([base_dir, '**','*.mov'].join('/'))
counter = 0
movies.each do |movie|
counter += 1
# next unless counter < 100
f =
new_path = [ target_dir, f.mtime.strftime("%Y/%Y-%m/%Y-%m-%d/%Y-%m-%d")].join('/')
FileUtils.mkdir_p (new_path) unless File.exists?(new_path)
new_path += '.' + File.basename(f)
printf("%04d: Renaming %s to %s\n", counter, f.path, new_path), new_path, :verbose => true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.