[Tutor] Scan Directory for files

Fred @ Mac fredp101 at mac.com
Sat Aug 2 07:41:06 CEST 2008


new to python, so please go easy on me!

I am using

for f in os.listdir(watch_dir):
         tree = ET.parse(f)
         for shot in tree.findall('Shot'):
		..do stuff..

to scan a directory for specific files (xml files specifically).

But my script fails if, for example, a directory also exists in  

How can i restructure this so it only returns a list of the .xml files  
in that directory, ignores other files and or directories in "watch_dir"


More information about the Tutor mailing list