I want to walk a directory and ignore all the files or directories which names begin in '.' (e.g. '.svn').
Then I will process all the files.
My test program walknodot.py does not do the job yet.
Please help.
#!c:/Python31/python.exe -u
import os
path = "C:\\test\\com.comp.hw.prod.proj.war\\bin"
for dirpath, dirs, files in os.walk(path):
print (dirpath)
print (dirs)
print (files)
for filename in files:
print ("filename " + filename)
print (dirs)
if "^.*" in dirs:
continue
if "^.*" in filename:
continue
print ("no . ")
# process the files here
C:\python>walknodot.py
C:\test\com.comp.hw.prod.proj.war\bin
[]
C:\test\com.comp.hw.prod.proj.war\bin\.svn
filename entries
no .
filename entries.bak
no .
C:\test\com.comp.hw.prod.proj.war\bin\.svn\prop-base
[]
[]
C:\test\com.comp.hw.prod.proj.war\bin\.svn\props
[]
[]
C:\test\com.comp.hw.prod.proj.war\bin\.svn\text-base
[]
[]
C:\test\com.comp.hw.prod.proj.war\bin\.svn\tmp
[]
C:\test\com.comp.hw.prod.proj.war\bin\.svn\tmp\prop-base
[]
[]
C:\test\com.comp.hw.prod.proj.war\bin\.svn\tmp\props
[]
[]
C:\test\com.comp.hw.prod.proj.war\bin\.svn\tmp\text-base
[]
[]
C:\test\com.comp.hw.prod.proj.war\bin\com
[]
C:\test\com.comp.hw.prod.proj.war\bin\com\comp
[]
C:\test\com.comp.hw.prod.proj.war\bin\com\comp\hw
[]
C:\test\com.comp.hw.prod.proj.war\bin\com\comp\hw\proj
[]
C:\test\com.comp.hw.prod.proj.war\bin\com\comp\hw\proj\war
['Activator.class', 'MessageReceiver.class', 'messages.properties', 'messages_fr.properties', 'ShutDownController.class', 'HwController
.class', 'HwManagerController.class']
filename Activator.class
no .
filename MessageReceiver.class
no .
filename messages.properties
no .
filename messages_fr.properties
no .
filename ShutDownController.class
no .
filename HwController.class
no .
filename HwManagerController.class
no .
C:\test\com.comp.hw.prod.proj.war\bin\com\comp\hw\proj\war\service
filename HwService.class
no .
C:\test\com.comp.hw.prod.proj.war\bin\com\comp\hw\proj\war\service\impl
[]
filename HwServiceImpl.class
[]
no .
filename HwServiceManager.class
[]
no .