Sha256: b8f68936dbf30bc0bb7f01da37377c07d70425204dce7f107aca199685696e65
Contents?: true
Size: 769 Bytes
Versions: 4
Compression:
Stored size: 769 Bytes
Contents
require "fileutils" module Tlapse class Util def self.organize!(dry_run: false) Dir["*.jpg"].each do |filename| normalize_path! filename, dry_run: dry_run end end def self.normalize_path!(file, dry_run: false) dirname = normalized_dirname(file) FileUtils.mkdir dirname unless File.exist? dirname || dry_run filename = normalized_filename(file) path = File.join dirname, filename puts "Rename #{file} to #{path}" FileUtils.mv file, path unless dry_run end def self.normalized_dirname(file) File.mtime(file).strftime(Tlapse::Capture.capture_dirname) end def self.normalized_filename(file) File.mtime(file).strftime(Tlapse::Capture.capture_filename) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
tlapse-0.9.0 | lib/tlapse/util.rb |
tlapse-0.8.0 | lib/tlapse/util.rb |
tlapse-0.7.0 | lib/tlapse/util.rb |
tlapse-0.6.3 | lib/tlapse/util.rb |