Skip to content

Instantly share code, notes, and snippets.

@yyjim
Created December 21, 2015 10:57
Show Gist options
  • Save yyjim/7a9b0367860d1acd0585 to your computer and use it in GitHub Desktop.
Save yyjim/7a9b0367860d1acd0585 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'fileutils'
working_dir = File.expand_path File.dirname(__FILE__)
["drawable-xxhdpi","drawable-xhdpi", "drawable-hdpi", "drawable-mdpi"].each do |dir|
directory = "#{working_dir}/#{dir}"
FileUtils.rm_rf(directory)
FileUtils.mkdir_p(directory)
end
Dir.entries(working_dir).each do |filename|
if filename =~ /(.*)_(x{0,2}h|m)(\..*)$/
new_file_name = "#{$1}#{$3}"
FileUtils.mv("#{working_dir}/#{filename}", "#{working_dir}/drawable-#{$2}dpi/#{new_file_name}", :force => true)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment