Skip to content

Instantly share code, notes, and snippets.

@kenyiu
Last active June 15, 2017 23:12
Show Gist options
  • Save kenyiu/2cf1c23fcd0abd3f82cfebd980b1b088 to your computer and use it in GitHub Desktop.
Save kenyiu/2cf1c23fcd0abd3f82cfebd980b1b088 to your computer and use it in GitHub Desktop.
Convert ios style assets to android style
#/bin/bash
mkdir -p "drawable-mdpi"
mkdir -p "drawable-hdpi"
mkdir -p "drawable-xhdpi"
mkdir -p "drawable-xxhdpi"
mkdir -p "drawable-xxxhdpi"
files="*.png"
regex="([^@])*@([0-9.]*)x\.png"
for f in $files
do
if [[ $f =~ $regex ]]
then
name="${BASH_REMATCH[1]}"
size="${BASH_REMATCH[2]}"
case $size in
1)
mv $f "drawable-mdpi/${name}.png"
;;
1.5)
mv $f "drawable-hdpi/${name}.png"
;;
2)
mv $f "drawable-xhdpi/${name}.png"
;;
3)
mv $f "drawable-xxhdpi/${name}.png"
;;
4)
mv $f "drawable-xxxhdpi/${name}.png"
;;
esac
else
echo "$f doesn't match" >&2 # this could get noisy if there are a lot of non-matching files
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment