Skip to content

Instantly share code, notes, and snippets.

@balysv
Created August 7, 2015 11:19
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 balysv/785137b6e78e1258dba6 to your computer and use it in GitHub Desktop.
Save balysv/785137b6e78e1258dba6 to your computer and use it in GitHub Desktop.
Small script to rename WebTranslateIt .xml files into Android Studio compatible format
## WebTranslateIt file rename utility
# Run this script in unzipped folder of
# .xml resources to move them into
# Android Studio compatible folder format
#
# ./strings.de.xml -> ./values-de/strings.xml
declare -A dirnames
# assosiative arrays dont allow empty keys
# so we add a space to every key. Meh
dirnames=(
["it "]="values-it"
["es "]="values-es"
["de "]="values-de"
["de-AT "]="values-de-rAT"
["de-CH "]="values-de-rCH"
["fr "]="values-fr"
[" "]="values"
)
for file in *.xml
do
name="${file%%.*}"
ext="${file#*.}"
dirkey=$(echo $ext | sed "s/\\.//g; s/xml/\ /g; ")
echo $dirkey
dirname="${dirnames["$dirkey"]}"
if [ ! -d $dirname ]; then
mkdir $dirname
fi
mv $file $dirname/$name.xml
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment