Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amsterdatech/1a11c7e2163803b98bcc5ac228fe8783 to your computer and use it in GitHub Desktop.
Save amsterdatech/1a11c7e2163803b98bcc5ac228fe8783 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