Created
March 5, 2020 05:47
-
-
Save hitesh-dhamshaniya/3d3b896529724394afd4621bf0887836 to your computer and use it in GitHub Desktop.
The gist will help you to remove all build folder from your android project and modules
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 | |
import shutil | |
import sys | |
if len(sys.argv)>1: | |
rootdir = sys.argv[1] | |
else: | |
# rootdir = os.path.dirname(os.path.realpath(__file__)) | |
#rootdir = 'D:\\example\\projects\\project name' | |
rootdir = 'D:\\AndroidStuioWS\\Good-work\\good-work-android' | |
print(rootdir) | |
# directory to be removed | |
rmDirs = ["build", ".gradle", ".settings", ".cxx", ".idea", ".externalNativeBuild"] | |
rmFiles = ('.iml') | |
for root, subdirs, files in os.walk(rootdir): | |
for dir in subdirs: | |
if dir in rmDirs: | |
try: | |
shutil.rmtree(os.path.join(root, dir)) | |
print("Delete Directory: " + os.path.join(root, dir)) | |
except FileNotFoundError as err: | |
print(err) | |
print("Delete Failed: " + os.path.join(root, dir)) | |
for file in files: | |
if file.endswith(rmFiles): | |
try: | |
os.remove(os.path.join(root, file)) | |
print("Delete File: " + os.path.join(root, file)) | |
except FileNotFoundError as err: | |
print(err) | |
print("Delete Failed: " + os.path.join(root, file)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment