Skip to content

Instantly share code, notes, and snippets.

@tondol
Created March 3, 2024 14:47
Show Gist options
  • Save tondol/4a2627296c1d5359bd4c46c6549dd561 to your computer and use it in GitHub Desktop.
Save tondol/4a2627296c1d5359bd4c46c6549dd561 to your computer and use it in GitHub Desktop.
require 'fileutils'
require 'pathname'
require 'pp'
nas_path = Pathname.new('/Volumes/photo')
card_path = Pathname.new(ARGV[0])
card_path.glob("DCIM/[0-9][0-9][0-9]CANON/*.{JPG,CR3}") {|path|
src_path = card_path / path
sday = File.birthtime(src_path).strftime('%Y%m%d')
dst_dir = nas_path / sday
FileUtils.mkdir_p(dst_dir) unless File.directory?(dst_dir)
FileUtils.mv(src_path, dst_dir)
puts ("%s -> %s" % [src_path, dst_dir])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment