Last active
August 29, 2015 14:21
-
-
Save igorglotov/c9ee3519ba947cb42169 to your computer and use it in GitHub Desktop.
Simple Android Assets Importer
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 | |
# Simple Android Assets Importer | |
# description: Sorts assets given by designer from file name postfix to | |
# android drawable directory structure | |
# | |
# for example: ic_launcher_xxhdpi.png to xxhdpi/ic_launcher.png | |
# | |
# usage: ./assets-sort.sh DIR DELIMITER | |
# example: ./assets-sort.sh Assets/ "_" | |
# note: no delimiter is used if not set by ARGV | |
# Created by Igor Glotov <igor.n.glotov@gmail.com> / github: igorglotov | |
# License: WTFPL | |
rm -rf $1/*dpi | |
files=`ls $1` | |
postfixes=("xxxhdpi" "xxhdpi" "xhdpi" "hdpi" "mdpi") | |
mkdir -p $1/{m,h,xh,xxh,xxxh}dpi | |
delim=$2 | |
for file in $files | |
do | |
for dpi in "${postfixes[@]}" | |
do | |
if [[ $file == *"$delim$dpi.png" ]] | |
then | |
newfile=${file%%"$delim$dpi.png"} | |
newfile=$newfile".png" | |
echo $newfile | |
cp $1/$file $1/$dpi/$newfile | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment