Created
November 5, 2014 14:15
-
-
Save greenrobot/ef9ea3be415952dc2855 to your computer and use it in GitHub Desktop.
Prepares iOS picture files for Android: images are renamed to conform with Android naming rules, and puts them into the correct drawable folder (-mdpi, -xhdpi, or -xxhdpi)
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
#!/bin/sh | |
mkdir drawable-mdpi | |
mkdir drawable-xhdpi | |
mkdir drawable-xxhdpi | |
shopt -s nocaseglob | |
for iosFile in *.{png,jpeg,gif}; do | |
if [[ ! -f $iosFile ]] | |
then | |
continue | |
fi | |
if [[ $iosFile == *@2* ]] | |
then | |
androidFile=${iosFile/@2x/} | |
dir=drawable-xhdpi | |
elif [[ $iosFile == *@3* ]] | |
then | |
androidFile=${iosFile/@3x/} | |
dir=drawable-xxhdpi | |
else | |
androidFile=$iosFile | |
dir=drawable-mdpi | |
fi | |
androidFile=`echo $androidFile | tr [:upper:] [:lower:]` | |
androidFile=${androidFile//-/_} | |
# Euro sign handling seems strange, so do it a bit differently... | |
#androidFile=${androidFile//[\€éèê]/eur} | |
euro=`echo -e "\xE2\x82\xAC"` | |
# Has to be replaced by exactly 3 characters, it seems... | |
androidFile=`echo $androidFile | tr $euro eur` | |
echo $iosFile \>\>\> $dir/$androidFile | |
cp $iosFile $dir/$androidFile | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment