Created
March 3, 2015 08:02
-
-
Save aviraldg/694a2a81e9bac16fb4ea to your computer and use it in GitHub Desktop.
Copy Android drawable resources.
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
#!/usr/bin/env python | |
import shutil, sys, os | |
def main(): | |
srcname = sys.argv[1] | |
destname = os.path.abspath(sys.argv[2]) | |
base = os.path.dirname(srcname) | |
srcname = os.path.basename(srcname) | |
def copy(arg, fname, fnames): | |
if os.path.basename(fname).startswith('drawable'): | |
for name in srcname.split(','): | |
src = os.path.abspath(os.path.join(fname, name)) | |
dest = os.path.abspath(os.path.join(destname, os.path.basename(fname), os.path.basename(src))) | |
if os.path.exists(src): | |
try: | |
os.makedirs(os.path.dirname(dest)) | |
except: | |
pass | |
print '%s -> %s' % (os.path.relpath(src), os.path.relpath(dest)) | |
shutil.copyfile(src, dest) | |
os.path.walk(base, copy, None) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment