Here's my code: def getFileList(): import os imageList = [] for dirpath, dirnames, filenames in os.walk(os.getcwd()): for filename in filenames: for dirname in dirnames: if not dirname.startswith('.'): if filename.lower().endswith('.jpg') and not filename.startswith('.'): imageList.append(os.path.join(dirpath, filename)) return imageList
I've adapted it around all the much appreciated suggestions. However, I'm running into two very peculiar logical errors. First, I'm getting repeated entries. That's no good. One image, one entry in the list. The other is that if I run the script from my Desktop folder, it won't find any files, and I make sure to have lots of jpegs in the Desktop folder for the test. Can anyone figure this out? [EMAIL PROTECTED] wrote: > I'm new at Python and I need a little advice. Part of the script I'm > trying to write needs to be aware of all the files of a certain > extension in the script's path and all sub-directories. Can someone > set me on the right path to what modules and calls to use to do that? > You'd think that it would be a fairly simple proposition, but I can't > find examples anywhere. Thanks. -- http://mail.python.org/mailman/listinfo/python-list