Created
October 7, 2015 20:11
-
-
Save mattprecious/113a163ce25efb87ab14 to your computer and use it in GitHub Desktop.
Rename iOS asset drops to match Android conventions. Deisgners, AMIRITE!?
This file contains 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
#!/usr/bin/python | |
import sys, re | |
def convert(s): | |
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', s) | |
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | |
if __name__ == '__main__': | |
if len(sys.argv) == 1: | |
s = sys.stdin.readlines()[0].strip() | |
elif len(sys.argv) == 2: | |
s = sys.argv[1] | |
else: | |
raise Exception() | |
print convert(s) |
This file contains 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
#!/bin/sh | |
declare -a densities=('mdpi' 'hdpi' 'xhdpi' 'xxhdpi' 'xxxhdpi') | |
declare -a scales=('1x' '1.5x' '2x' '3x' '4x') | |
i=0 | |
while [ $i -lt ${#densities[@]} ]; do | |
density=${densities[i]} | |
scale=${scales[i]} | |
for f in *${scale}.png; do | |
if [ -f $f ]; then | |
folder=drawable-${density} | |
if [ ! -d ${folder} ]; then | |
mkdir ${folder} | |
fi | |
destination=${folder}/$(echo $f | sed -e "s/${scale}//g" | camel-to-snake.py) | |
mv $f $destination | |
fi | |
done | |
let i=i+1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment