Skip to content

Instantly share code, notes, and snippets.

@hitesh-dhamshaniya
Created March 5, 2020 05:47
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 hitesh-dhamshaniya/3d3b896529724394afd4621bf0887836 to your computer and use it in GitHub Desktop.
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
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