Created
August 7, 2015 11:19
-
-
Save balysv/785137b6e78e1258dba6 to your computer and use it in GitHub Desktop.
Small script to rename WebTranslateIt .xml files into Android Studio compatible format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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