Skip to content

Instantly share code, notes, and snippets.

@mattak
Created April 9, 2013 11:59
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 mattak/5345136 to your computer and use it in GitHub Desktop.
Save mattak/5345136 to your computer and use it in GitHub Desktop.
change directory {xx} -> drawable-{yy}dpi/
#!/bin/sh
#
# change dpi directory
#
# 36 -> ldpi
# 48 -> mdpi
# 72 -> hdpi
# 96 -> xhdpi
#
if [ $# -lt 1 ]; then
echo "usage: [directory] [dpi_depth]?"
exit 0
fi
DIR=$1
DEPTH=0
if [ $# -gt 1 ]; then
DEPTH=$2
fi
cd $DIR
SRC_DIRS=(`find . -type d -depth 1 | sort`)
DST_DIRS=(drawable-ldpi drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi)
(( DIRSIZE = ${#SRC_DIRS[*]} -1 ))
for i in `seq 0 $DIRSIZE`
do
(( j = $i + $DEPTH ))
echo mv ${SRC_DIRS[$i]} ${DST_DIRS[$j]}
mv ${SRC_DIRS[$i]} ${DST_DIRS[$j]}
done
cd - > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment