Skip to content

Instantly share code, notes, and snippets.

@dgrant
Last active December 14, 2015 22:18
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 dgrant/5156911 to your computer and use it in GitHub Desktop.
Save dgrant/5156911 to your computer and use it in GitHub Desktop.
Remove all .svn dirs recursively under the given path
#!/usr/bin/env python
"""Remove all .svn directories"""
import os
import shutil
def remove_dot_svn_dirs(root):
"""Remove all .svn directories root"""
for root, dirs, _ in os.walk(root):
for adir in dirs:
if adir == '.svn':
fullpath = os.path.join(root, adir)
shutil.rmtree(fullpath)
def main():
"""Main function that handles all command line parsing"""
from optparse import OptionParser
usage = "usage: %prog [options] directory"
parser = OptionParser(usage)
_, args = parser.parse_args()
if len(args) < 1:
parser.error("A directory must be specified")
remove_dot_svn_dirs(args[0])
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment