in Linux, Python

Recurse through directory (Python Style)

So i recently had an issue with the .svn directories that svn creates in each and every folder in a version controlled project. I figured i could delete the offending .svn directories by writing a small script. Here is what i ended up with:

from os.path import join, getsize
import os,shutil
for root, dirs, files in os.walk(‘<project path here >’):
for x in dirs:
if x == ‘.svn’:
print “removing ..” + root + “/” + x
shutil.rmtree(root + “/” + x

Hope it helps someone else 😉

  • Tk

    or $ rm -rf `find project -name .svn`
    🙂

    • Yeah, and you could do that too.

      on my mobile