Created
December 6, 2018 00:31
-
-
Save henriquemenezes/e6f64f15d6cea1bda39a7bf9cbed68f0 to your computer and use it in GitHub Desktop.
Android Move Drawable
This file contains 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
#!/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