I am trying to select particular files within a particular subdirectory, I
have been able to do both but not together!
When I try to select my files within the dir loop nothing comes up, but when
I leave the files outside the dir loops it selects all the files
not just the ones in the dirs I have selected.
The code I am using is:
import os
MainFolder=r"D:/samples/"
for (path, dirs, files) in os.walk(MainFolder):
for dir in dirs:
if dir=='01':
print "selected directories are:",dir
for ncfile in dir:
if ncfile[-3:]=='.nc':
print "ncfiles are:", ncfile
Any feedback will be greatly appreciated!!
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor