Created
October 3, 2013 22:19
-
-
Save caseymonc/6818012 to your computer and use it in GitHub Desktop.
Convert image resource files from an iOS project to image resource files with correct names and in proper directories for an Android project
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/bash | |
if [ -z "$1" ] | |
then | |
echo "Please enter the directory where your ios resource files reside" | |
else | |
if [ -z "$2" ] | |
then | |
echo "Please enter the base directory where you want your android resources to reside" | |
else | |
lowDir="$2/drawable-ldpi" | |
mediumDir="$2/drawable-mdpi" | |
highDir="$2/drawable-hdpi" | |
extraHighDir="$2/drawable-xhdpi" | |
mkdir -p "$lowDir" | |
mkdir -p "$mediumDir" | |
mkdir -p "$highDir" | |
mkdir -p "$extraHighDir" | |
for f in `ls $1/*.png`; do | |
filename=$(basename "$f") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
filename="`echo $filename | tr "[:upper:]" "[:lower:]"`" | |
filename="`echo ${filename//-/_}`" | |
filename="`echo ${filename// /_}`" | |
HOST=user1 | |
if [[ $filename == *@2x* ]] ; | |
then | |
filename="`echo ${filename//@2x/}`" | |
#Copy file to large and xlarge dir | |
cp "$f" "$highDir/$filename.png" | |
cp "$f" "$extraHighDir/$filename.png" | |
else | |
#Copy file to medium and small dir | |
cp "$f" "$lowDir/$filename.png" | |
cp "$f" "$mediumDir/$filename.png" | |
fi | |
done | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment