Created
May 2, 2015 05:12
-
-
Save dgrant/26341c2b2fdc74594d04 to your computer and use it in GitHub Desktop.
Remove non .svn dirs
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 directories except .svn directories""" | |
import os | |
def remove_non_dot_svn_dirs(root): | |
"""Remove all directories except .svn directories under too""" | |
for dirpath, _, files in os.walk(root): | |
if dirpath.find('.svn') == -1: | |
for afile in files: | |
fullpath = os.path.join(dirpath, afile) | |
print "Removing", fullpath | |
os.remove(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_non_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