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
Post a Comment