Created
November 5, 2015 23:00
-
-
Save tristanm/12a732e53313157c62be to your computer and use it in GitHub Desktop.
Ruby image file duplicator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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