Skip to content

Instantly share code, notes, and snippets.

@tristanm
Created November 5, 2015 23:00
Show Gist options
  • Save tristanm/12a732e53313157c62be to your computer and use it in GitHub Desktop.
Save tristanm/12a732e53313157c62be to your computer and use it in GitHub Desktop.
Ruby image file duplicator
require 'fileutils'
glob_path = File.join(
Rails.application.config.retail_plus_images_path,
'*.{jpg,jpeg,png,gif}'
)
Dir.glob(glob_path).each do |src|
basename = File.basename(src, '.*')
dest = src.gsub(basename, basename + '_2')
FileUtils.cp(src, dest)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment