samedi 3 mars 2007

[Python]: find files of a certain type in a folder.

To search for .jpg files in the folder "myfoder" you can do:


import os,fnmatch

for fileName in os.listdir ( "myfolder" ):
if fnmatch.fnmatch ( fileName, '*.jpg' ):
print "Found fileName ",fileName

Aucun commentaire: