Anyway to use file masks with os.listdir()?

ScherBi at BAM.com ScherBi at BAM.com
Tue Nov 16 11:46:35 EST 1999


use glob.

eg:

DIR = "/home/spam"
files = glob.glob(DIR + "/*.jpg")

will get you a list of all the .jpg files in /home/spam


Bill Scherer

> -----Original Message-----
> From: Aaron J Reichow [mailto:reic0024 at ub.d.umn.edu]
> Sent: Tuesday, November 16, 1999 10:29 AM
> To: python-list at python.org
> Subject: Anyway to use file masks with os.listdir()?
> 
> 
> 
> Is there any way to pass a filemask to os.listdir()?  For 
> example, to list
> only files with the extension .jpg.  Any help would be appreciated! :)
> 
> Aaron
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list