Skip to content

Instantly share code, notes, and snippets.

@eefret
Last active March 7, 2016 21:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eefret/8681652fb037b7b5a566 to your computer and use it in GitHub Desktop.
Save eefret/8681652fb037b7b5a566 to your computer and use it in GitHub Desktop.
Sometimes in Android development you find designers that make your assets names with "-" this makes the android compiler to fail as assets cannot have "-", I create this script to solve this problem recursively renaming the files and replacing "-" with "_" plus making them lowercase.
#!/bin/bash
# Normalize assets
# Sometimes in Android development you find designers that make your assets names with "-" this makes
# the android compiler to fail as assets cannot have "-", I create this script to solve this problem
# recursively renaming the files and replacing "-" with "_" plus making them lowercase.
#
# Instructions:
# 1- Move this script to your Android {PROJECT_BASE_FOLDER}/app/src/main/res
# 2- run it with sudo ex: "sudo ./rename_script.sh"
for f in drawable-*/*; do
MYDIR=$(dirname $f) # Obtaining dirname
MYFILE=$(basename $f) # Obtaining filename
SUB=`echo $MYFILE | sed 's/-/_/g' | tr [:upper:] [:lower:]` # Replacing "-" in filename for "_" plus making lowercase
echo "Moving File $MYDIR/$MYFILE -> $MYDIR/$SUB" #printing info to double check
mv $MYDIR/$MYFILE $MYDIR/$SUB #moving old file to new file (need sudo)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment