Skip to content

Instantly share code, notes, and snippets.

@mrhether
Last active January 10, 2017 15:58
Show Gist options
  • Save mrhether/1900e48dcb01fa4f5f97a02d0337402c to your computer and use it in GitHub Desktop.
Save mrhether/1900e48dcb01fa4f5f97a02d0337402c to your computer and use it in GitHub Desktop.
Allows you to move resources from one android app/lib to another
import os, sys
if len(sys.argv) < 4:
print "Family you need 3 params, originalFolder, newResFolder, fileName"
else:
orginalResFolder = sys.argv[1]
newResFolder = sys.argv[2]
fileNames = sys.argv[3:]
print "files to move " + str(fileNames)
for fileName in fileNames:
pathDictionary = {}
os.listdir(orginalResFolder)
for dirpath, dirnames, filenames in os.walk(orginalResFolder):
for name in filenames:
if "build" not in dirpath and name.lower() == fileName.lower():
fullPath = dirpath + "/" + name
pathDictionary[os.path.basename(dirpath)] = fullPath
newResPath = ""
for dirpath, dirnames, filenames in os.walk(newResFolder):
for name in filenames:
if "build" not in dirpath and "res" in dirpath:
newResPath = dirpath.split("res")[0] + "res/"
break
for key, value in pathDictionary.iteritems():
oldPath = value
newDir = newResPath + key + "/"
newpath = newDir + fileName
print "MOVE"
print "From: " + oldPath
print "To: " + newpath
if not os.path.exists(newDir):
os.makedirs(newDir)
os.rename(oldPath, newpath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment