Forked from henriquemenezes/android-move-drawable.rb
Created
February 18, 2020 04:19
-
-
Save amsterdatech/1a11c7e2163803b98bcc5ac228fe8783 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