How do I recursively remove all the directories and files which begin with '.'? My test program rmdir.py does not do the job yet. Please help. [code] #!c:/Python31/python.exe -u import os from shutil import *
root = "C:\\test\\com.comp.hw.prod.proj.war\\bin" for curdir, dirs, files in os.walk(root): print (curdir) print (dirs) for d in dirs: print ("d " + d) if d.startswith('.'): print ("dotd " + os.path.join(curdir, d)) rmtree(os.path.join(curdir, d)) [/code] C:\python>rmdir.py C:\test\com.comp.hw.prod.proj.war\bin ['.svn', 'com'] d .svn dotd C:\test\com.comp.hw.prod.proj.war\bin\.svn Traceback (most recent call last): File "C:\python\rmdir.py", line 14, in <module> rmtree(os.path.join(curdir, d)) File "C:\Python31\lib\shutil.py", line 235, in rmtree onerror(os.remove, fullname, sys.exc_info()) File "C:\Python31\lib\shutil.py", line 233, in rmtree os.remove(fullname) WindowsError: [Error 5] Access is denied: 'C:\\test\ \com.comp.hw.prod.proj.war\\bin\\.svn\\entries' -- http://mail.python.org/mailman/listinfo/python-list