Skip to content

Instantly share code, notes, and snippets.

@igorglotov
Last active August 29, 2015 14:21
Show Gist options
  • Save igorglotov/c9ee3519ba947cb42169 to your computer and use it in GitHub Desktop.
Save igorglotov/c9ee3519ba947cb42169 to your computer and use it in GitHub Desktop.
Simple Android Assets Importer
#!/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