Skip to content

Instantly share code, notes, and snippets.

@henriquemenezes
Created December 6, 2018 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save henriquemenezes/e6f64f15d6cea1bda39a7bf9cbed68f0 to your computer and use it in GitHub Desktop.
Save henriquemenezes/e6f64f15d6cea1bda39a7bf9cbed68f0 to your computer and use it in GitHub Desktop.
Android Move Drawable
#!/usr/bin/env ruby
require 'fileutils'
prefix_input = ARGV[0]
prefix_output = ARGV[1]
suffixes = [".png", "@1.5x.png", "@2x.png", "@3x.png", "@4x.png"]
output_dirs = {
".png" => "drawable-mdpi",
"@1.5x.png" => "drawable-hdpi",
"@2x.png" => "drawable-xhdpi",
"@3x.png" => "drawable-xxhdpi",
"@4x.png" => "drawable-xxxhdpi"
}
suffixes.each do |suffix|
begin
output_dir = output_dirs[suffix]
print "Moving #{prefix_input}#{suffix} -> #{output_dir}/#{prefix_output}.png ... "
FileUtils.mv("#{prefix_input}#{suffix}", "#{output_dir}/#{prefix_output}.png")
puts "OK"
rescue => e
puts "FAIL"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment