Skip to content

Instantly share code, notes, and snippets.

@greenrobot
Created November 5, 2014 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenrobot/ef9ea3be415952dc2855 to your computer and use it in GitHub Desktop.
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)
#!/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