Skip to content

Instantly share code, notes, and snippets.

@Maxr1998
Last active September 20, 2015 13:36
Show Gist options
  • Save Maxr1998/b772eb3ff775cbead46b to your computer and use it in GitHub Desktop.
Save Maxr1998/b772eb3ff775cbead46b to your computer and use it in GitHub Desktop.
Android Drawable Autocopy
#!/bin/bash
###############################################################################
# Android Drawable Autocopy #
# Copyright (C) 2015 Max Rumpf alias Maxr1998 #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
###############################################################################
#
# This shell script automatically copies drawables from icon libraries to your project folder.
# (For example the material design icons by Google)
# You have to specify the path of where the drawable folders sit, your res folder, and the name of the file you want to copy
#
# Syntax: <scriptname.sh> <path to library folder> <path to project folder> <file name>
# Note: paths cannot be relative and must have a / at the end.
#
# Example: ./autocopy $HOME/Res/material-design-icons/action/ $HOME/projects/MyApp/app/src/main/res/ ic_delete_black_24dp.png
drawableFolders=(drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi drawable-xxxhdpi)
if [ $# -lt 3 ] || [ $1 == "-h" ]
then
echo "Syntax: <scriptname.sh> <path to library folder> <path to project folder> <file name>"
exit
fi
for i in "${drawableFolders[@]}"
do
FILE="$1$i/$3"
TARGET_DIR="$2$i/"
if [ -e "$FILE" ]
then
if [ ! -e $TARGET_DIR ]
then mkdir $TARGET_DIR
fi
cp $FILE $TARGET_DIR$3
fi
done
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment