Skip to content

Instantly share code, notes, and snippets.

@denysxftr
Created June 30, 2015 19:51
Show Gist options
  • Save denysxftr/3b9e72e714386e7fcdeb to your computer and use it in GitHub Desktop.
Save denysxftr/3b9e72e714386e7fcdeb to your computer and use it in GitHub Desktop.
folder_path = ENV['FOLDER']
from = Regexp.new(ENV['FROM'])
to = ENV['TO']
Dir.glob(folder_path + "*").sort.each do |f|
filename = File.basename(f, File.extname(f))
new_filename = filename.gsub(from, to)
File.rename(f, folder_path + new_filename + File.extname(f))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment