class PhotoHelper::Move
Public Instance Methods
jpeg(folder = nil)
click to toggle source
# File lib/photo-helper/move.rb, line 17 def jpeg(folder = nil) folder ||= options[:folder] puts folder search_path = File.expand_path(folder) files = if options[:recursive] Dir["#{search_path}/**/*.{#{JPEG_EXTENSIONS.join(",")}}"] else Dir["#{search_path}/*.{#{JPEG_EXTENSIONS.join(",")}}"] end files.each do |file| next if FileHelper.ingore_file?(file) relative_path = Pathname.new(file).relative_path_from(Pathname.new(PHOTOS_ROOT)).to_s new_path = File.join(JPEG_ROOT, relative_path) path_dir = File.dirname(new_path) FileUtils.mkdir_p path_dir unless File.exists? path_dir FileUtils.mv file, new_path end end