To get the full path in your list-- change Kent's to this
import os
filelist = []
for root,directories,filenames in os.walk("Aircraft"):
for filename in filenames:
if filename.endswith("-set.xml"):
filelist.append(os.path.join(root,filename))
for x in filelist:
print xWhat I want to do is rather simple, but I cannot find any good documentation for something like this.
The directory structure is sort of like this:AircraftA-10+A-10cl-set.xml +A-10fg-set.xml
For example Aircraft/A-10/A-10cl-set.xml
Now I want to loop though each aircrafts folder (such as A-10) and find each *-set.xml file, get the aircraft part (such as A-10cl) and add it to a list.
While this does seem simple, how is the question.
I know about the walk function, but cannot find any good examples for it. -- <Arthur/> _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
