Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Python, fastest way to build a list of files in a directory with a certain extension

In Python on a GNU/Linux system, what's the fastest way to recursively scan a directory for all .MOV or .AVI files, and to store them in a list?

like image 354
ensnare Avatar asked Dec 24 '11 17:12

ensnare


1 Answers

You can use os.walk() for recuresive walking and glob.glob() or fnmatch.filter() for file matching:

Check this answer

like image 121
Aleksandra Zalcman Avatar answered Sep 23 '22 09:09

Aleksandra Zalcman