Last active
August 29, 2015 14:09
-
-
Save krpiotrek/96b2cd2f12781197fb8b to your computer and use it in GitHub Desktop.
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
import os, sys, shutil | |
MDPI_DIR = 'drawable-mdpi' | |
HDPI_DIR = 'drawable-hdpi' | |
XHDPI_DIR = 'drawable-xhdpi' | |
XXHDPI_DIR = 'drawable-xxhdpi' | |
XXXHDPI_DIR = 'drawable-xxxhdpi' | |
OUTPUT_DIRECTORY = "outputs" | |
def find(name, path): | |
for root, dirs, files in os.walk(path): | |
if name in files: | |
return os.path.join(root, name) | |
else: | |
raise RuntimeError('file ' + path + ' not found') | |
def createDirIfNotExists(dir): | |
if not os.path.exists(dir): | |
os.makedirs(dir) | |
def createOutputsDir(): | |
createDirIfNotExists(OUTPUT_DIRECTORY) | |
createDirIfNotExists(OUTPUT_DIRECTORY + "/" + MDPI_DIR) | |
createDirIfNotExists(OUTPUT_DIRECTORY + "/" + HDPI_DIR) | |
createDirIfNotExists(OUTPUT_DIRECTORY + "/" + XHDPI_DIR) | |
createDirIfNotExists(OUTPUT_DIRECTORY + "/" + XXHDPI_DIR) | |
createDirIfNotExists(OUTPUT_DIRECTORY + "/" + XXXHDPI_DIR) | |
currentDirectory = os.getcwd() | |
category = sys.argv[1] | |
fileName = sys.argv[2] | |
PATH = currentDirectory + "/" + category + "/" | |
mdpiFile = find(fileName, PATH + MDPI_DIR) | |
hdpiFile = find(fileName, PATH + HDPI_DIR) | |
xhdpiFile = find(fileName, PATH + XHDPI_DIR) | |
xxhdpiFile = find(fileName, PATH + XXHDPI_DIR) | |
xxxhdpiFile = find(fileName, PATH + XXXHDPI_DIR) | |
createOutputsDir() | |
shutil.copy2(mdpiFile, OUTPUT_DIRECTORY + "/" + MDPI_DIR) | |
shutil.copy2(hdpiFile, OUTPUT_DIRECTORY + "/" + HDPI_DIR) | |
shutil.copy2(xhdpiFile, OUTPUT_DIRECTORY + "/" + XHDPI_DIR) | |
shutil.copy2(xxhdpiFile, OUTPUT_DIRECTORY + "/" + XXHDPI_DIR) | |
shutil.copy2(xxxhdpiFile, OUTPUT_DIRECTORY + "/" + XXXHDPI_DIR) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use with https://github.com/google/material-design-icons, place script in material-design-icons root directory, run in terminal f.e
python copy_material_icons.py social ic_cake_black_18dp.png