Last active
December 14, 2015 22:18
-
-
Save dgrant/5156911 to your computer and use it in GitHub Desktop.
Remove all .svn dirs recursively under the given path
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
#!/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