Skip to content

Instantly share code, notes, and snippets.

@mattprecious
Created October 7, 2015 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattprecious/113a163ce25efb87ab14 to your computer and use it in GitHub Desktop.
Save mattprecious/113a163ce25efb87ab14 to your computer and use it in GitHub Desktop.
Rename iOS asset drops to match Android conventions. Deisgners, AMIRITE!?
#!/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)
#!/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