How can I efficiently select 100 random JPG files from a directory (including subdirs) in Python? -


i have large directory of files , folders. currently, scan entire directory jpgs , store them in list. slow due size of directory. there faster, more efficient way this? perhaps without scanning everything?

my directory looks this:

/library/modified/2000/[foldername]/images.jpg /library/modified/2001/[foldername]/images.jpg /library/modified/2002/[foldername]/images.jpg /library/modified/2003/[foldername]/images.jpg /library/modified/2004/[foldername]/images.jpg ... /library/modified/2012/foldername/images.jpg 

thanks

see generator tricks system programmers bunch of neat stuff. specifically, see gen-find example. efficient going get, without making bunch of assumptions file structure layout.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -