newb question: file searching

jaysherby at gmail.com jaysherby at gmail.com
Tue Aug 8 18:01:35 EDT 2006


Okay.  This is almost solved.  I just need to know how to have each
entry in my final list have the full path, not just the file name.
Also, I've noticed that files are being found within hidden
directories.  I'd like to exclude hidden directories from the walk, or
at least not add anything within them.  Any advice?

Here's what I've got so far:

def getFileList():
	import os
	imageList = []
	for files in os.walk(os.getcwd(), topdown=True):
		imageList += [file for file in files[2] if file.endswith('jpg') or
file.endswith('gif')]
	return imageList




More information about the Python-list mailing list